0

I'm using RCaller in order to call R from java programs The pc where I'm trying to call R by using RCaller can't access to Internet; now I have this situation: from Java I write me R code and, by using RCode I add this code to R; the generated code is this one:

packageExist<-require(Runiversal)
if(!packageExist){
  install.packages("Runiversal", repos=" http://cran.r-project.org")
}

source("/tmp/liveness/helper.R")
source("/tmp/liveness/model-nbd.R")
source("/tmp/liveness/model-pareto-nbd.R")
source("/tmp/liveness/model-bg-nbd.R")
source("/tmp/liveness/model-cbg-cnbd-k.R")
cdData <- read.table("/tmp/liveness/data.csv", head=T)
names(cdData)[2] <- "x";
bgMleFit <- bgEstimateParameters(cdData, list(r=1, alpha=2, a=1, b=2));
summary(bgMleFit);
cdBgParams <- as.list(coef(bgMleFit));
t <- 2;
cdBgCe <- bgConditionalForecast(cdData, cdBgParams, t);
cat(makexml(obj=cdBgCe, name="cdBgCe"), file="/tmp/Routput7266683884330110613")

By executing this code in the Java program I have an exception when I try to parse the XML file because the generate XML file is empty If I copy the generated code and paste it in RStudio all works pretty good

Cœur
  • 37,241
  • 25
  • 195
  • 267
Angelo Immediata
  • 6,635
  • 4
  • 33
  • 65
  • What is empty, the XML file RCaller generates and passes on to R or the file that R returns, `/tmp/Routput7266683884330110613` ? – mbatchkarov Jul 12 '13 at 09:01

2 Answers2

1

The way I solved it: (I'm using 64 bit version of R), so in the code I just changed the line: caller.setRscriptExecutable("C:/Program Files/R/R-3.0.1/bin/Rscript"); to the following line: caller.setRscriptExecutable("C:/Program Files/R/R-3.0.1/bin/x64/Rscript.exe");

(please note that I'm using RCaller-2.0.7.jar as source). it's attached

0

new version of this library is a little bit faster, does not require the R package Runiversal and some bugs had been fixed. Try it out Here

jbytecode
  • 681
  • 12
  • 29