cost p
cost p

Reputation: 3

How can I add an R script on my web application?

I am trying to run an R script on my web application. The script runs perfectly on R studio. I am using the Renjin package.

This is what i am trying to run

private void scriptREval() throws Exception {
        RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
        ScriptEngine engine = factory.getScriptEngine();

        try {
            engine.eval("library(openxlsx)");
            engine.eval("library(deSolve)");
            engine.eval("file<- filename");
            // Load data from the Excel file
            engine.eval("SB.K <- as.matrix(read.xlsx(file, colNames = FALSE, namedRegion = 'K'))");
            engine.eval("SB.m0 <- read.xlsx(file, colNames = FALSE, namedRegion = 'm0')");
            } catch (ScriptException e) {
                e.printStackTrace();
        }
}

these are the dependencies I am using

<dependency>
   <groupId>org.renjin</groupId>
   <artifactId>renjin-script-engine</artifactId>
   <version>0.9.2726</version>
</dependency>
<dependency>
   <groupId>org.renjin.cran</groupId>
   <artifactId>openxlsx</artifactId>
   <version>4.1.0.1-b1</version>
</dependency>
   <dependency>
   <groupId>org.renjin.cran</groupId>
   <artifactId>deSolve</artifactId>
   <version>1.23-b1</version>
</dependency>

However there is a problem with the openxlsx library thus I cannot perform further calculations. org.renjin.eval.EvalException: object 'C_unzip' not found

Any help please?

Upvotes: 0

Views: 57

Answers (0)

Related Questions