<div dir="ltr"><div class="gmail_extra">Hi, Romain,</div><div class="gmail_extra"> </div><div class="gmail_extra">Thanks a lot for the quick reply !!<br></div><div class="gmail_extra">Suffix with << L >> works for me for both Rf_isInteger and is<int>.</div>
<div class="gmail_extra"><br> </div><div class="gmail_quote">On Mon, Jun 9, 2014 at 12:43 PM, Romain François <span dir="ltr"><<a href="mailto:romain@r-enthusiasts.com" target="_blank">romain@r-enthusiasts.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><br>
Le 9 juin 2014 à 21:40, Chaomei Lo <<a href="mailto:chaomeilo@gmail.com">chaomeilo@gmail.com</a>> a écrit :<br>
<div><br>
><br>
> I have a R list something like this -<br>
><br>
> op=list(a=200, b="test", c=4.5)<br>
> when I pass it as an argument to Rcp Export function which the code looks like this in below.<br>
><br>
> ----------------------------------------<br>
> int n = xlist.length();<br>
> for (int I=0; I < n; I++) {<br>
>   SEXP s = xlist[I];<br>
>   if (Rf_isInteger(s)) {<br>
>   //do something<br>
>   }<br>
>   else if (Rf_isNumerc(s)) {<br>
>   //do other thing<br>
>   }<br>
>   else if (Rf_isString(s)) {<br>
>   //do other thing<br>
>   }<br>
> }<br>
><br>
> However, both a and c go to the Rf_isNumeric if statement; but the first one is an integer,<br>
<br>
</div>no it’s not.<br>
<br>
> str( 200 )<br>
 num 200<br>
> str( 200L )<br>
 int 200<br>
> str( as.integer(200) )<br>
 int 200<br>
<br>
Suffix with « L » or use as.integer if you want an integer.<br>
<br>
Alternatively, Rcpp has is<>, so you can use<br>
<br>
if( is<int>(s) ) {<br>
    ...<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
Romain<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> not sure why it did not go to into the Rf_isInteger if statement.<br>
><br>
> Thanks.<br>
<br>
<br>
</div></div></blockquote></div><div class="gmail_extra"><br></div></div>