Song Baiyi <[EMAIL PROTECTED]> writes:

>     for(i = 0; i < n ; i++)
>         val = (double)REAL(eval(VECTOR_ELT(e,i), R_GlobalEnv))[0];
...
> eval_R_command("mean(1:5)")
> it worked fine and got 3,
> 
> but
> 
> eval_R_command("sum(1:5)")
> it produced a strange number 7.41098e-323! not 15
> 
> What is the problem?

You have a sum of integers, so the result is integer and you access it
as a REAL. You need explicit coercion, or to use
eval_R_command("as.double(sum(1:5))") 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])             FAX: (+45) 35327907

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to