> I am very new to c++ so I apologize in advance if this is a stupid question:

I ran into this myself when I started using Rcpp  -- it's a good
question.  The R API is extensive, but it's vanilla C and doesn't
handle vectors (and you already know how to sample() a scalar,
right?).

> For a larger analysis I am trying to implement the R function sample() in c++ 
> via RcppArmadillo.

There's a non-trivial penalty for reaching back into R for functions
that aren't exported via the API (e.g. "Rcpp::Function sample =
base["sample"];").  Rcpp Vectors are STL containers, and many folk
have asked the same questions wrt the STL.  There's some good
background reading here:
http://stackoverflow.com/questions/6942273/get-random-element-from-container-c-stl

Christian
-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to