在OS 10.8.2上安装R库XLConnect

时间:2013-03-08 21:52:35

标签: r excel xlconnect

正如手册所描述的那样,

XLConnect是“允许从R内读取,写入和操作Microsoft Excel文件的软件包”。

在Windows和Linux上安装非常简单。简单地告诉R install.packages("XLConnect"),你已经完成了。在OS X上,您需要使用install.packages("XLConnect", type="source"),安装说明如下。

在OS 10.8.2下尝试此操作,R输出许多错误消息。我将它们发布在此处,因此Google可以向此Q和A发送类似问题的人。要解决此问题,请向下滚动。


R输出:

> install.packages("XLConnect", type = "source")
also installing the dependencies ‘XLConnectJars’, ‘rJava’

versuche URL 'http://ftp5.gwdg.de/pub/misc/cran/src/contrib/XLConnectJars_0.2-4.tar.gz'
Content type 'application/x-gzip' length 16539227 bytes (15.8 Mb)
URL geöffnet
==================================================
downloaded 15.8 Mb

versuche URL 'http://ftp5.gwdg.de/pub/misc/cran/src/contrib/rJava_0.9-3.tar.gz'
Content type 'application/x-gzip' length 537153 bytes (524 Kb)
URL geöffnet
==================================================
downloaded 524 Kb

versuche URL 'http://ftp5.gwdg.de/pub/misc/cran/src/contrib/XLConnect_0.2-4.tar.gz'
Content type 'application/x-gzip' length 1719698 bytes (1.6 Mb)
URL geöffnet
==================================================
downloaded 1.6 Mb

* installing *source* package ‘rJava’ ...
** Paket ‘rJava’ erfolgreich entpackt und MD5 Summen überprüft
/Library/Frameworks/R.framework/Resources/bin/config: line 142: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 143: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 219: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 142: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 143: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 219: make: command not found
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
ERROR: dependency ‘rJava’ is not available for package ‘XLConnectJars’
* removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/XLConnectJars’
ERROR: dependencies ‘XLConnectJars’, ‘rJava’ are not available for package ‘XLConnect’
* removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/XLConnect’

Die heruntergeladenen Quellpakete sind in 
    ‘/private/var/folders/some/path/to/downloaded_packages’
Warnmeldungen:
1: In install.packages("XLConnect", type = "source") :
 Installation des Pakets ‘rJava’ hatte Exit-Status ungleich 0
2: In install.packages("XLConnect", type = "source") :
 Installation des Pakets ‘XLConnectJars’ hatte Exit-Status ungleich 0
3: In install.packages("XLConnect", type = "source") :
 Installation des Pakets ‘XLConnect’ hatte Exit-Status ungleich 0
> library(XLConnect)
Fehler in library(XLConnect) : es gibt kein Paket namens ‘XLConnect’

1 个答案:

答案 0 :(得分:7)

Mac OSX上的安装比installation instructions建议的要复杂一点。该软件包的开发人员Mirai Solutions的Martin Studer帮我解决了我的困难,我想在这里发布这个程序,以帮助其他用户遇到同样的问题。

  1. 安装Java
    出于安全考虑,最新版本的OS X没有Java。如果您从使用Java的版本更新,它将被卸载! Check,如果你有Java。如果没有,download并安装它。
  2. 安装rJava
    您将(稍后)从源安装XLConnect,因为OS X没有二进制文件。在此安装过程中,当R尝试安装依赖包rJava时,您将收到错误,因为必须从二进制文件安装。因此,您必须先使用左install.packages("rJava")
  3. 进行安装
  4. 安装XLConnect
    最后,从源代码安装XLConnect:
    install.packages("XLConnect", type="source")