I suspect the intend is to send a value from R to compiled code. Which
happens to be a problem for which Rcpp offers a pretty convenient solution.
And if you really, really want to, you can even program in C inside of an
Rcpp interface:
R> cppFunction("int foo(std::string txt) { Rprintf(\"Var
What does c_fun look like? Here's mine:
#include
#include
void c_fun(){
printf("TMP is %s\n", getenv("TMP"));
}
and I then do this at the shell prompt:
R CMD SHLIB c_fun.c
and this at the R prompt:
dyn.load("c_fun.so")
wrapper()
and I get:
> wrapper()
[1] "A"
TMP is A
list()
Is that
wrapper <- function(){
Sys.setenv(TMP="A")
print(Sys.getenv("TMP"))
.C("c_fun")
}
As the example above, I hope to set an env var $TMP inside the R function
"wrapper", which affects the functionality of the C function call "c_fun".
Also the print line shows that $TMP is set to be "A", but t