How to return R NULL to Rcpp code?

Suppose I have C ++ code to compile with Rcpp and is invoked in R.

// [[Rcpp::export]] SEXP to_env(List x) { if(x.hasAttribute("names")) { return x; } else { return NULL; } } 

What NULL should return R NULL instead of failing?

+6
source share
1 answer

Use this code:

 return R_NilValue; 
+12
source

Source: https://habr.com/ru/post/974796/


All Articles