Hi, Romain, Thanks a lot for the quick reply !! Suffix with << L >> works for me for both Rf_isInteger and is<int>.
On Mon, Jun 9, 2014 at 12:43 PM, Romain François <[email protected]> wrote: > > Le 9 juin 2014 à 21:40, Chaomei Lo <[email protected]> a écrit : > > > > > 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, > > no it’s not. > > > str( 200 ) > num 200 > > str( 200L ) > int 200 > > str( as.integer(200) ) > int 200 > > Suffix with « L » or use as.integer if you want an integer. > > Alternatively, Rcpp has is<>, so you can use > > if( is<int>(s) ) { > ... > } > > Romain > > > not sure why it did not go to into the Rf_isInteger if statement. > > > > Thanks. > > >
_______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
