I have a R script in which I want to call parameters from Java code. The parameters are csv file name
file name and unique ID
which has to be used to name the two output files.
My R script is :
df1 <- read.csv("filename.csv")
vs=colnames(df1)
md=formula(paste(vs[3],"~",vs[1],"+",vs[2]))
fit <- summary(aov(md, data=df1))[[1]]
#text output
names(fit)[1:4]=c("DF","SS","MS","F")
sink("test.txt")
In this code the first line df1 <- read.csv("filename.csv")
should take file name dynamically from JAVA code
and the last line sink("test.txt")
should take unique ID
and create the output file.
The java code is :
buildCommand.add("Rscript ");
buildCommand.add(scriptName);
buildCommand.add(inputFileWithPathExtension);
buildCommand.add(uniqueIdForR);
I have seen other post but I am unsure wether it will help in my case, also similar posts talking about rJava
package`, but didn't get clear idea.
Any help will be highly appreciated. thanks in advance !