如何在foreach中指定R软件包的位置(...,.packages =" pkg")%dopar% [英] How to specify the location of R packages in foreach( ... , .packages="pkg") %dopar%
本文介绍了如何在foreach中指定R软件包的位置(...,.packages =" pkg")%dopar%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的pkg被安装在别的地方,我怎么能告诉foreach在哪里找到这个软件包?
foreach(i = 1:2,.packages =pkg)%dopar%{...}
给我错误信息:
pre $ 工人初始化失败:没有包叫'pkg'
$ c $
感谢您的帮助。
您可以使用 .libPaths()
函数在运行会话中设置库路径。
否则启动文件(如〜/ .Renviron
)可以提供帮助,请参阅?启动
。
最后,如果您使用 foreach
来运行不同的机器,需要照顾每台机器上的库路径。
My "pkg" was installed somewhere else, how could I tell foreach where to find the package?
foreach(i = 1:2,.packages="pkg") %dopar% { ... }
This give me error message:
worker initialization failed: there is no package called 'pkg'
Thank you for your help.
解决方案
You could use the .libPaths()
function to set a library path in a running session.
Otherwise the startup files such as ~/.Renviron
can help, see the ?Startup
.
Lastly, if you use foreach
to run of different machines, you need to take care of the library path on each of the machines.
这篇关于如何在foreach中指定R软件包的位置(...,.packages =" pkg")%dopar%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文