rplotjri

save R image plot via org.rosuda.jri.rengine


I use org.rosuda.jri lib to run an R script that implements the ordinary kirging algorithm via java. I use ubuntu 13.04 and the version 1.7-3 of REngine While all the results are perfectly produced BUT i can not create the plots and store them.

while the following lines are perfectly executed in R console

png('/home/panisis/Desktop/plots/tralala.png');
spplot(df);
dev.off();

These ones are ignored

re.eval("png('/home/panisis/Desktop/plots/tralala.png');"); 
re.eval("spplot(df);");
re.eval("dev.off();");

What i am missing??? Thanks for the dedicated time. :-)


Solution

  • i just found the answer myself. i put it here for next users. i had to assign the plot to a temporary variable (like temp <- spplot()) and then use print(temp) to save it as png file for example temp <- spplot() png(filename="pathToFile") print(temp) dev.off()