Blog Archives

STL transform + remove_copy for subsetting

December 29, 2012
By

We have seen the use of the STL transform functions in the posts STL transform and Transforming a matrix. We use the same logic in conjuction with a logical (ie boolean) vector in order subset an initial vector. #include <Rcpp.h> using namespace...

Read more »

STL Transform

December 28, 2012
By

The STL transform function can be used to pass a single function over a vector. Here we use a simple function square(). #include <Rcpp.h> using namespace Rcpp; inline double square(double x) { return x*x ; } // ] std::vector<...

Read more »