[英]Install R Package XML in Debian / Ubuntu
I am just getting started with Ubuntu and want to program in R. I successfully installed the latest version of R (currently 2.12.2) from the terminal. 我刚刚开始使用Ubuntu并希望在R中编程。我从终端成功安装了最新版本的R(目前为2.12.2)。 I then attempted to run the following command:
然后我尝试运行以下命令:
> install.packages("XML")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("XML") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to create a personal library
'~/R/i686-pc-linux-gnu-library/2.12'
to install packages into? (y/n)
Should I create the personal directory or did I miss a step somewhere that allows me to write to the site library. 我应该创建个人目录还是错过了允许我写入站点库的某个步骤。
Thanks in advance. 提前致谢。
The comment by sarnold
is quite correct. sarnold
的评论非常正确。 In the Debian (and hence Ubuntu) package, the directory /usr/local/lib/R/site-library/
is created by the file /var/lib/dpkg/info/r-base-core.postinst
script -- and the relevant code is: 在Debian(以及Ubuntu)包中,目录
/usr/local/lib/R/site-library/
由文件/var/lib/dpkg/info/r-base-core.postinst
脚本创建 - 和相关代码是:
# edd 03 Apr 2003 cf Section 10.1.2 of Debian Policy
if [ ! -e /usr/local/lib/R ]; then
if mkdir /usr/local/lib/R 2>/dev/null; then
chown root:staff /usr/local/lib/R
chmod 2775 /usr/local/lib/R
fi
fi
if [ ! -e /usr/local/lib/R/site-library ]; then
if mkdir /usr/local/lib/R/site-library 2>/dev/null; then
chown root:staff /usr/local/lib/R/site-library
chmod 2775 /usr/local/lib/R/site-library
fi
fi
so the directory is owned by root:staff
and of mode 2775, or 'user and group read-write, others read-only'. 因此该目录由
root:staff
和2775模式所有,或者“用户和组读写,其他只读”。
So to write there, you have two basic choices: 所以要写在那里,你有两个基本选择:
Always use sudo
or become root
which is clumsy. 总是使用
sudo
或成为笨拙的root
。
Add yourself to the group staff
. 将自己添加到小组
staff
。 There is probably a user-friendly GUI for it; 它可能有一个用户友好的GUI; I am Unix old-school and do that by hand by editing
/etc/group
and /etc/gshadow
-- after that you can install directly (well you need a fresh shell to have those rights, or just start a new terminal). 我是Unix老派,通过编辑
/etc/group
和/etc/gshadow
手动完成 - 之后你可以直接安装(你需要一个新的shell来拥有这些权利,或者只是启动一个新的终端)。 You can of course also pick a different group, or create one, but then you need to also alter the directory tree in /usr/local/lib/R/
accordingly. 您当然也可以选择一个不同的组,或者创建一个组,但是您还需要相应地更改
/usr/local/lib/R/
的目录树。
Hope this helps. 希望这可以帮助。 The r-sig-debian list is a friendly place for Debian/Ubuntu questions like this and I recommend it.
r-sig-debian列表是这样的Debian / Ubuntu问题的友好地方,我推荐它。 The question has come up there before.
之前的问题出现了。
Edit: Also, a fair number of (more complicated) packages are part of Ubuntu / Debian, so to get XML you can just to sudo apt-get install r-cran-xml
. 编辑:此外,相当数量的(更复杂的)软件包是Ubuntu / Debian的一部分,所以要获得XML,你只需要
sudo apt-get install r-cran-xml
。 Do an apt-cache search r-cran
to see what is available. 做一个
apt-cache search r-cran
来查看可用的内容。
The simplest option is to add yourself to the staff
user group. 最简单的选择是将自己添加到
staff
用户组。 Just run: 赶紧跑:
sudo adduser <user> staff
Replace <user>
with your username. 用您的用户名替换
<user>
。
Tested in Ubuntu 14.04 在Ubuntu 14.04中测试过
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.