I want to generate R boxplot by using rcaller with java. My code is:
Try {RCaller caller = new RCaller (); Caller.setRExecutable ("/ usr / bin / r"); Caller.setGraphicsTheme (new default theme) ()); Encoded code = new encoded (); Code.clear (); File file = code.startplate (); Code.addRCode ("boxplot ((1:10), main = \" 1-10 \ ");); Println (code.toString ()); Code.endPlot (); Caller.setRCode (code); Caller.runAndReturnResultOnline ("boxplot (1:10), main = \" 1-10 \ ""); Code.showPlot (file); But this code does not run on the caller.runAndReturnResultOnline ("boxplot (1:10), main = \" 1-10 \ ""); I try to use the code given below, which can plot R Plot. What is the difference between them?
try {RCaller caller = new RCaller (); Caller.setRExecutable ("/ usr / bin / r"); Caller.setGraphicsTheme (new default theme) ()); Encoded code = new encoded (); Code.clear (); Double [] number = new double [] {1, 4, 4, 5, 6, 10}; Code.addDoubleArray ("x", number); File file = code.startplate (); Println (file.toString ()); Code.addRCode ("plot.ts (x)"); Println (code.toString ()); Code.endPlot (); Caller.setRCode (code); Caller.runAndReturnResultOnline ("plot.ts (x)"); Code.showPlot (file); Change your line: code.addRCode ("Boxplot ((1:10), main = \" 1-10 \ ");); From:
code.addRCode ("boxplot (c (1:10), main = '1-10');); Or as another example, you can give your X vector to Java and change this line: caller.runAndReturnResultOnline ("plot.ts (x ) "); by
caller.runAndReturnResultOnline ("boxplot (x)"); PS: I do not have Java for testing.
No comments:
Post a Comment