Say that you pass an environment R object to an internal C routine through the .Call interface. Said enviromnent has (by design) a someObject object which I want to extract and manipulate from the C side. How to do it?
To simplify my question, I just want to write a C function that returns someObject. Like this:
en <- new.env()
en$someObject <- someValue
.Call("extractObject",en)
#the above should return en$someObject
Guess the C code should then look something like
SEXP extractObject(SEXP env) {
return SOMEMACROORFUNCTION(env, "someObject");
}
Unfortunately, I was not able to find the real SOMEMACROORFUNCTION.
After a little bit of googling and searching, I've found the solution:
findVar(install("someObject"),env)
in the C code is basically the equivalent of get("someObject",env) in R.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With