I am writing program using RCaller 2.1.1-SNAPSHOT. Problem is when I use code from external library it says Routput file is empty. Here is my code:
Random random = new Random();
RCaller caller = new RCaller();
RCode code = new RCode();
caller.setRscriptExecutable("C:/Program Files/R/R-2.14.2/bin/x64/Rscript.exe");
double[] data = new double[100];
for (int i = 0; i < data.length; i++) {
data[i] = random.nextGaussian();
}
code.addDoubleArray("x", data);
code.addRCode("setwd('C:/Radek/')");
code.addRCode("wd=list.files()");
code.addRCode("library(Biobase)");
//code.addRCode("targets=read.AnnotatedDataFrame('targets.txt',row.names=1,as.is=TRUE)");// WHEN I USE THIS IT CRASH
code.addRCode("my.mean<-mean(x)");
code.addRCode("my.var<-var(x)");
code.addRCode("my.sd<-sd(x)");
code.addRCode("my.min<-min(x)");
code.addRCode("my.max<-max(x)");
code.addRCode("my.standardized<-scale(x)");
code.addRCode(
"my.all<-list(mean=my.mean, variance=my.var, sd=my.sd, min=my.min, max=my.max, std=my.standardized)");
caller.setRCode(code);
caller.runAndReturnResult("wd");
String[] results;
results = caller.getParser().getAsStringArray("wd");
System.out.println("Mean is " + results[0]);
I checked this: 1. RUniversal is installed and loaded 2. library for using function is downloaded and installed. 3 When I put rCaller request from file generated by RCaller into R it works. 4. slashes in RScript path are good because I checked results with commented problematic line and it works.
Can someone help me with this?