[R] A question about embedded R
song.baiyi at udo.edu
Tue Apr 6 12:26:49 CEST 2004
I met a strange problem when I call R expression from C++, here is the
I edited a function eval_R_command();
double eval_R_command(const char *funcName)
ParseStatus status = PARSE_OK;
SET_STRING_ELT(exp, 0, COPY_TO_USER_STRING(funcName));
PROTECT(e = R_ParseVector(exp, 1, &status));
n = GET_LENGTH(e);
for(i = 0; i < n ; i++)
val = (double)REAL(eval(VECTOR_ELT(e,i), R_GlobalEnv));
Then if i call with
it worked fine and got 3,
it produced a strange number 7.41098e-323! not 15
What is the problem?
By the way which is the better way to call the function in R from C++,
or they are same?
1. Pass the whole expression as string to R
2. Use Rf_findFun
Thank you very much!
Dortmund University, Germany
More information about the R-help