user1467830
user1467830

Reputation: 31

Websockets service method fails during R startup

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

Upvotes: 3

Views: 218

Answers (1)

GSee
GSee

Reputation: 49820

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.

Upvotes: 3

Related Questions