Skip to content
Prev 35576 / 63424 Next

how to call a function from C

Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as 
one function-like class and seems to be behave reasonably while a lot of 
other things seem more urgent to sort out.
Using R_tryEval() will let you evaluate an expression in a given 
environment, as well as capture an eventual error occurring during its 
evaluation (and translate it as an exception).
Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for 
"do_try_eval". The behavior looks very similar, the above snippet in 
rpy2 would write like:

from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)