Friday, 15 April 2011

How do I give an R variable a name from C code -



How do I give an R variable a name from C code -

does know how programatically assign value "named" value in r internals, (e.g. 'x')

my application has calculated value (in case x) , want pass variable r script (which run via r_eval), don't know how tell r info 'x'

sexp info rf_protect(data = rf_allocvector(realsxp, 1))); double dval = 5.0 real(data)[j] = dval; // thought might have assign attribute doesn't seem work. // rf_setattrib(data, r_namesymbol, rf_mkchar("x")); //code run supplied script utilize x won't define y <- c(1,2,3,x) summary(c)

at nowadays getting parse error of 'object 'x' not found'

many thanks

paul

so on farther digging seems possible accomplish wanted doing following.

sexp variablename= rf_install(const_cast<char*>("x")); rf_definevar(variablename, data, _r_globalenv);

r

No comments:

Post a Comment