Skip to content
Prev 2142 / 10988 Next

[Rcpp-devel] Boolean vector from R to C++

Hi all,

I am trying to pass on a boolean vector from R to C++. I have naively 
tried the following:

################################
src <- '
   using namespace Rcpp ;
   using namespace std ;
   int b = as<bool>(xb);
return wrap(b);'
cxxfun <- cxxfunction(sig=signature(xb="logical"),
                       body=src,plugin="Rcpp",verbose=TRUE)
cxxfun(b);

Error in cxxfun(b) : expecting a single value
###############################

Is there an equivalent to IntegerVector or NumericVector for Boolean 
variables or can I simply use the Rcpp::Vector template for this purpose?

Thanks for your help,