[R] JRI API: sourcing from Java String

Romain Francois romain.francois at dbmail.com
Wed Apr 28 16:05:38 CEST 2010


Le 28/04/10 15:40, Ralf B a écrit :
>
> Hi all,
>
> I have been using 'source(filename)' to load R code from a file
> object. However, now I have a special case where I don't have a file
> since I am loading an R script from a Jar file. I would like to avoid
> creating temporary files. Is there a way to use the 'source' command
> with a Java String? Are there any other, better ways to do that?
>
> Ralf

You can parse the String using parse and then eval the result using eval.

You can do both at once using parseAndEval

You can assign the String to some R variable ( say FOO) using assign, 
and then in R do something like : eval( parse( text = FOO ) )

Questions about JRI, rJava, REngine, etc ... usually belong to the 
stats-rosuda-devel mailing list: 
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7



More information about the R-help mailing list