1

I can run the R-script below from the Windows-command line. The script loads a fitted neuralnet from my harddisk and makes a prediction based on x1 and x2.

Although I do not see nnetTune in the Global Environment (which would be the case if I run the code from the R-Console). If I call the script again without the line load("D:/nnetTune.rda") it does not work since it needs nnetTune. I don't want to load nnetTune again every time I run the script. My questions are:

1) Where is nnetTune if it is not loaded visible in the Global Environment? 2) Is there a method so I need only once to load nnetTune into memory and not for every call from the script?

x1 <- 12
x2 <- 22

load("D:/nnetTune.rda")

xx <- data.frame(x1, x2)
names(xx) <- c("predictor1","predictor2")
z <- predict(nnetTune, xx)
z

I have checked these posts although I can't find an answer:

http://shashiasrblog.blogspot.com/2013/10/vba-front-end-for-r.html

Run R script from command line

Thanks!

Marcel
  • 115
  • 2
  • 15
  • What exactly is `nnetTune`? I don't understand what you are asking. If you are running for the command line, you are running a new instance of R each time. When that script is done,R unloads itself. There is global environment that persistent between instances of R when run from the command line. You must load all the data you need each time. That said, R also can save a workspace file for you so when you restart it it will automatically load all the files that were in the workspace before. That data is stored in an ".Rdata" file were the script was run (or the last working directory was set). – MrFlick Sep 21 '18 at 17:31
  • @ MrFlick thanks, that is the answer to my question. nnetTune is a neural network. So I conclude that I have to load into memory every time I run the script. – user2165379 Sep 22 '18 at 19:03

0 Answers0