Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websockets service method fails during R startup

Tags:

r

websocket

I would like to run websockets inside R when R is starts up. I use websockets package: http://cran.r-project.org/web/packages/websockets/. If I run the example from this distribution on Windows by setting follow in Rprofile.site:

.First <- function()
{
   source("C:\\R\\orig-websockets.R")
}

I'm getting follow error:

Error in .parse_header(x) : could not find function "tail"

Trace is follow:

6: .parse_header(x)
5: service(w) at orig-websockets.R#26
4: eval.with.vis(expr, envir, enclos)
3: eval.with.vis(ei, envir)
2: source("C:\\R\\orig-websockets.R")
1: .First()

I assume the problem in some package dependencies. Same script works fine if loaded manually.

Thank you in advance.

Ilya

like image 554
user1467830 Avatar asked Dec 27 '25 22:12

user1467830


1 Answers

tail is in the utils package. You need to add require("utils") either to the .First function before you source the script or at the top of the script.

From ?Startup

... if a function .First is found on the search path, it is executed as .First(). Finally, function .First.sys() in the base package is run. This calls require to attach the default packages specified by options("defaultPackages").

In other words, utils isn't loaded until after the .First function has been executed.

like image 144
GSee Avatar answered Dec 30 '25 10:12

GSee