Change Log for version 0.5.2: | |
|
|
|
[2010/08/07] Now, Rcaller has a new version, 0.5.2, with some bug fixes and additional functionality. Some changes are done and some bugs are fixed by John Oliver. John is now second developer of the Rcaller. |
|
Examples | |
1)Getting Pi from R!In this example, we are calling R code "a<-pi;" that sets the value of pi to variable a. Then, we handle this result from Java.
The result is 3.14159. RCaller always handles results as arrays, so a is not variable but double array. Array has only one element, so a[0] is the value that sent from R. We have to use cat(makejava(a)) to make R object 'a' usable in Java. We call RunRCode() function with 3 parameters. Last 2 parameters are boolean. If first one is true, then content of stderr will be written on console. If the second one is true, then content of stdout will be written. We set them false not to write both outputs on the screen. | |
2)Calculate Linear Regression from Java using RIn this example, we set x and y with random variables that come from standard normal distributions and estimate linear regression using R and Java.
The result is -0.815634476060036 0.637334790434423 so, these are the estimated coefficients of the ordinary least squres regression. | |
3)Running RCaller in different platforms (Linux, Windows, Mac, etc)RCaller is pure Java and can be run any platform that Java virtual machine runs. Also, you need to be have R as well. Default R engine is Rscript executable file that distrubited in R. Default value of engine is /usr/bin/Rscript but user can change location using setRScriptExecutableFile(String location) method.
| |
4)What objects returned after running my R command?RCaller converts R objects to Java objects. You can handle returned values' names like this:
The result is: double[] residuals double[] coefficients double[] sigma double[] df double[] rsquared double[] adjrsquared double[] fstatistic double[] covunscaled double[] residuals double[] coefficients double[] sigma double[] df double[] rsquared double[] adjrsquared double[] fstatistic double[] covunscaled and these are all returned fields from the summary() R command. |