无法在Ubuntu 11.04中安装R包

Der*_*ang 125 xml installation ubuntu r

我是Linux和R的新手.

我在Ubuntu 11.04中安装了R 2.12.今天我尝试安装一个新包,所以我运行了以下命令:

install.packages('XML')
Run Code Online (Sandbox Code Playgroud)

但安装失败并提供以下信息:

* installing *source* package ‘XML’ ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
No ability to remove finalizers on externalptr objects in this verison of R
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package ‘XML’
* removing ‘/home/spirit/R/i686-pc-linux-gnu-library/2.12/XML’

The downloaded packages are in
    ‘/tmp/RtmpoZYxnv/downloaded_packages’
Warning message:
In install.packages("XML") :
  installation of package 'XML' had non-zero exit status
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

sudo install.packages('XML')
Run Code Online (Sandbox Code Playgroud)

但它提供了相同的错误信息.

任何人都可以给我任何建议吗?提前致谢.

csg*_*pie 202

install.packages方法

你需要安装ubuntu包libxml2-dev所以在shell提示符下输入:

sudo apt-get update
sudo apt-get install libxml2-dev
Run Code Online (Sandbox Code Playgroud)

你需要特殊的sudo权力.

Ubuntu包方法

正如Richie和Dirk所提到的,你也可以使用:

sudo apt-get install r-cran-xml
Run Code Online (Sandbox Code Playgroud)

如果你走这条路,我会建议您检查出的[R Ubuntu的资源页面,这将确保你有R和当前版本相关的R程序包.如果您使用的是UTSntu的LTS版本,这可能很重要.


Dir*_*tel 27

科林的答案在狭义上是正确的,但同时你可以说是错误的

 sudo apt-get install r-cran-xml
Run Code Online (Sandbox Code Playgroud)

因为XML是Ubuntu中可用的CRAN包之一.难道apt-cache search r-cran-*你看到了别人.