Load variable once in DeployR

325 Views Asked by At

I have a model trained and stored in a file called "rpartModel.RData", in my R script to use this model in DeployR, I need to load the model every time the script is called. There is any way to load the file only once and the variable be used in the R scripts?

My code:

library(caret)
load("rpartModel.RData") #no way to run just once and be used as global?
predict(fitRPart,kyphosis[10,])
1

There are 1 best solutions below

0
On

Found it.

Using the RBroker I can espcify a file to be preloaded, like in this java example https://github.com/deployr/java-example-fraud-score/blob/master/src/main/java/com/revo/deployr/rbroker/example/service/FraudService.java .

PoolPreloadOptions preloadOptions = new PoolPreloadOptions();
preloadOptions.filename = "rpartModel.rData";