[Rcpp-devel] Handling NULL values

Dirk Eddelbuettel edd at debian.org
Fri Jun 17 13:30:25 CEST 2011


[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

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com


More information about the Rcpp-devel mailing list