R 启动期间 Websockets 服务方法失败 [英] Websockets service method fails during R startup

查看:23
本文介绍了R 启动期间 Websockets 服务方法失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 R 启动时在 R 中运行 websockets.我使用 websockets 包:http://cran.r-project.org/web/packages/websockets/.如果我通过在 Rprofile.site 中设置 follow 在 Windows 上运行此发行版中的示例:

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")
}

我收到以下错误:

.parse_header(x) 中的错误:找不到函数tail"

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

跟踪如下:

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.

提前致谢.

伊莉雅

推荐答案

tail 位于 utils 包中.您需要在源脚本之前或脚本顶部将 require("utils") 添加到 .First 函数.

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.

来自 ?Startup

... 如果在搜索路径上找到一个函数 .First,它会作为 .First() 执行.最后,运行基础包中的函数 .First.sys().此调用需要附加由 options("defaultPackages") 指定的默认包.

... 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").

换句话说,utils 直到 after .First 函数被执行后才会被加载.

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

这篇关于R 启动期间 Websockets 服务方法失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆