How to create a new R environment from C?

I could not find the documentation for this. It looks like the source code for R uses NewEnvironment and R_NewHashedEnv , but none of them are in public headers, so it seems like they are not available to me as a user. Which function (or lines of code) should I use to create a new ENVSXP?

+6
source share
1 answer

Do you want allocSExp :

 /* C code in foo.c */ #include "Rinternals.h" SEXP foo() { SEXP res = allocSExp(ENVSXP); return res; } 

 > # R code (after running R CMD SHLIB foo.c) > dyn.load("foo.dll") > .Call("foo") <environment: 0x016a4084> 
+3
source

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


All Articles