is it possible to run R as a daemon
Asked Answered
L

2

9

I have a script in R that is frequently called during the day (by other scripts). I call R in a terminal using

Rscript code.R

I notice it takes a lot of time to load packages and set up R.

Is it possible to run R as a background service which I hit using a port or something?

Lovellalovelock answered 10/1, 2017 at 13:27 Comment(0)
T
8

Yes, look into RServe which has been available for over a dozen years for this reason. There are a couple of fairly high profile applications too.

Tidwell answered 10/1, 2017 at 15:52 Comment(4)
+1. It’s worth noting that RServe is of course not necessary — one can simply use Rscript/littler/whatever to execute a normal R scrip that sets up its own TCP/IP listener.Assuntaassur
True -- and things like rzmq even make to possible to 'serve' easily. RServe is still more general in offering the full REPL.Tidwell
@DirkEddelbuettel Would it be possible to load up trained models (.RDA) and and libraries also?Lovellalovelock
Yes, as there are essentially no limits to what R scripts you can load at startup of the session started by Rserve.Tidwell
A
0

You can check out this add-in for Rstudio, it is not a port like solution but maybe it can help you https://github.com/bnosac/taskscheduleR

Auberge answered 12/1, 2017 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.