0

I need to load a library every time I am making a new RConnection. Is it possible to have it pre-loaded when I start RServe?

Loading it every time a new RConnection is making it slower.

Nitin
  • 3
  • 3
  • Tried like this: Rserve(debug=FALSE, port=6312, eval=library(forecast), wait=FALSE) But it didnt work... Need help to start Rserve with a preloaded library. – Nitin Feb 20 '15 at 19:27
  • This looks to be a duplicate of question: http://stackoverflow.com/questions/31433840/rserve-share-library-code – Daniel Neel Jul 17 '15 at 20:31

3 Answers3

5

Yes, you can use eval or source configuration options or --RS-source <file> command line option. Anything you load this way is pre-loaded into the server before it starts listening for connections.

Simon Urbanek
  • 13,842
  • 45
  • 45
  • Here's an example of what this would look like on Linux: `R CMD Rserve --RS-source ~/Desktop/SomeApplication/rserve-config/SomeApplication.conf` Drop this into a bash script, and you can start the server with all libraries loaded simply. – Daniel Neel Jul 17 '15 at 20:34
  • @DanielNeel didn't you confuse `--RS-conf` with `--RS-source` which AFAIK should points to R file. – jangorecki Nov 26 '15 at 18:50
  • @jangorecki That's possible, I'm not sure - I don't have access to my R setup currently. If anyone can verify this, I can edit my comment. – Daniel Neel Nov 26 '15 at 22:03
4

It might not be working because you're missing the quotes around the library name. Another way to do it is to put the eval line inside /etc/Rserve.conf like this:

eval library('lib1'); library('lib2'); library('lib3')
Zzzz
  • 61
  • 1
  • 3
0

Finally after all the research I have found that RConnection only can be loaded with library, and every RConnection needs to be initialized with all the libraries and packages.

We just need to optimize the way we are using our RConnection.

Nitin
  • 3
  • 3