[Rcpp-devel] type information about elements in Rcpp::List

Chaomei Lo chaomeilo at gmail.com
Mon Jun 9 21:40:20 CEST 2014


I have a R list something like this -

op=list(a=200, b="test", c=4.5)
when I pass it as an argument to Rcp Export function which the code looks
like this in below.

----------------------------------------
int n = xlist.length();
for (int I=0; I < n; I++) {
  SEXP s = xlist[I];
  if (Rf_isInteger(s)) {
  //do something
  }
  else if (Rf_isNumerc(s)) {
  //do other thing
  }
  else if (Rf_isString(s)) {
  //do other thing
  }
}

However, both a and c go to the Rf_isNumeric if statement; but the first
one is an integer, not sure why it did not go to into the Rf_isInteger if
statement.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140609/05ff76ae/attachment.html>


More information about the Rcpp-devel mailing list