[Rd] Build a R call at C level

Morgan Morgan morg@n@em@||box @end|ng |rom gm@||@com
Tue Jun 30 11:08:10 CEST 2020


Hi All,

I was reading the R extension manual section 5.11 ( Evaluating R expression
from C) and I tried to build a simple call to the sum function. Please see
below.

call_to_sum <- inline::cfunction(
  language = "C",
  sig = c(x = "SEXP"), body = "

SEXP e = PROTECT(lang2(install(\"sum\"), x));
SEXP ans = PROTECT(eval(e, R_GlobalEnv));
UNPROTECT(2);
return ans;

")

call_to_sum(1:3)

The above works. My question is how do I add the argument "na.rm=TRUE" at C
level to the above call? I have tried various things based on what is in
section 5.11 but I did not manage to get it to work.

Thank you
Best regards

	[[alternative HTML version deleted]]



More information about the R-devel mailing list