On 28/04/2010 9:40 AM, Ralf B wrote:
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?

source(x) is basically the same as eval(parse(x)) with bells and whistles added. Since parse() accepts a text= argument that is an R character vector, you could do what you want by converting your Java string to an R string and calling eval and parse directly. Alternatively, if you need the bells and whistles, you can use textConnection to create a connection from an R string and source() that.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to