[Rcpp-devel] Idiom for accessing scalars
Hadley Wickham
hadley at rice.edu
Wed Jan 4 14:29:54 CET 2012
Hi all,
I'm still just getting my feet wet in Rcpp, so please excuse the
naivety of my question, but is this the appropriate idiom for treating
an input as a C++ scalar?
f <- cxxfunction(signature(x = "integer"), plugin = "Rcpp", '
Rcpp::IntegerVector x1(x);
int x2 = x1[0];
return(Rcpp::NumericVector(x2));
')
i.e. is there any way I can turn x in x2 more succinctly? (This
function is just for illustrative purposes - I'm trying to do
something at least a little more complicated)
Thanks!
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the Rcpp-devel
mailing list