问题
Suppose I have a C++ code to compile with Rcpp and will be called in R.
// [[Rcpp::export]]
SEXP to_env(List x) {
if(x.hasAttribute("names"))
{
return x;
}
else
{
return NULL;
}
}
What should the NULL
value be to return R's NULL
instead of a crash?
回答1:
Use this code:
return R_NilValue;
来源:https://stackoverflow.com/questions/25658225/how-to-return-rs-null-in-rcpp-code