[Rcpp-devel] Handling NULL values

Serge Iovleff Serge.Iovleff at univ-lille1.fr
Fri Jun 17 22:23:48 CEST 2011


Hi Dirck,

Thanks for your answer.

I did not take care that in a Rcpp list when I access to the element like this

algoOptions_["nbTry"]

I get a SEXP element

Thanks
Serge


Le 17.06.2011 13:30, Dirk Eddelbuettel a écrit :
> [resending, this time with CC to list. --Dirk]
>
> Hi Serge,
>
> On 17 June 2011 at 09:56, Serge Iovleff wrote:
> | How can I test if a member of a list is a NULL value ?
>
> Recall that Rcpp is 'merely' a higher-level C++ interface playing along and
> on top of the R API itself --- so for questions like this check the R
> headers, documentation and 'Writing R Extensions' manual.
>
> In this case, per the Rinternals.h header:
>
> /* Various tests with macro versions below */
> Rboolean (Rf_isNull)(SEXP s);
> Rboolean (Rf_isSymbol)(SEXP s);
> Rboolean (Rf_isLogical)(SEXP s);
> Rboolean (Rf_isReal)(SEXP s);
> Rboolean (Rf_isComplex)(SEXP s);
> Rboolean (Rf_isExpression)(SEXP s);
> Rboolean (Rf_isEnvironment)(SEXP s);
> Rboolean (Rf_isString)(SEXP s);
> Rboolean (Rf_isObject)(SEXP s);
>
> so   Rf_isNull( someSexpVar )   is what you want.  Works for any SEXP whether
> you access it as a single var, or pick it from a list.
>
> Hope this helps, Dirk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4154 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110617/e81de46a/attachment.bin>


More information about the Rcpp-devel mailing list