安装可供所有用户使用的 R 软件包
我在 ~/R/i486-pc-linux-gnu-library/2.11
下安装了一些 R 软件包。
我想让它们以及我从现在开始安装的任何其他 R 软件包可供所有 R 用户使用。我不介意在一个中立的地方重新安装我已经拥有的软件包(它们只是几个)。那么我该怎么做呢?
I have a few R packages installed under ~/R/i486-pc-linux-gnu-library/2.11
.
I would like to make them, and any other R package I install from now on, available to all R users. I don't mind re-installing the packages I already have in a neutral place (they are just a few). So how do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
aL3xa 答案是错误的;您不应该公开这些目录以供所有用户写入。
以 root 身份运行 R(可能使用 sudo R),然后照常安装软件包——它们将被放置在全局库中,并且可供所有用户使用。
aL3xa answer is wrong; you shouldn't expose those directories to write for all users.
Run R as a root (probably using
sudo R
) and then install packages as usual -- they will be placed in a global library and will be available for all users.就您而言,最简单的方法是以 root 身份安装软件包(如果是 Windows,则以管理员身份安装),它们可供该计算机上的每个用户使用。
In your case, the easiest way would be to install the packages as root (or as administrator in case of Windows), they'll be available for every user on that machine.
aL3xa 给出了(恕我直言)不好的建议。不要弄乱由包管理系统处理的
/usr
。相反,请使用 /usr/local/lib/R/site-library 提供的工具。默认情况下已搜索后一个目录。您需要做的就是将自己添加到
staff
组中,因为该组在那里有写入权限 - 尝试adduser yourid Staff
,其中yourid
是您在系统上的用户名。之后您应该能够毫无问题地安装在那里。在 Ubuntu 上您可能喜欢的另一件事是 apt-get install Littler,然后使用示例中的 install.r 和 upload.r 帮助程序脚本目录。我一直在使用它们。
aL3xa gives (IMHO) bad advice. Do not mess with
/usr
which is handled by the package management system. Instead, use the facility provided by/usr/local/lib/R/site-library
.That latter directory is already searched by default. All you need to do is to add yourself to group
staff
as that group has write-rights there -- tryadduser yourid staff
whereyourid
is your user name on the system. Afterwards you should be able to install there without problems.Another thing you may like on Ubuntu is
apt-get install littler
and then use theinstall.r
andupgrade.r
helper scripts from the examples directory. I use them all the time.