#ifndef dplyr_wrap_subset_H #define dplyr_wrap_subset_H namespace dplyr { template SEXP wrap_subset(SEXP input, const Container& indices) { int n = indices.size(); Rcpp::Vector res = Rcpp::no_init(n); typedef typename Rcpp::traits::storage_type::type STORAGE; STORAGE* ptr = Rcpp::internal::r_vector_start(input); for (int i = 0; i < n; i++) res[i] = ptr[ indices[i] ]; return res; } } #endif