我正在尝试安装R软件包fGarch,但似乎存在问题。我使用以下命令:
import rpy2.interactive as r
import rpy2.interactive.packages
rlib = r.packages.packages
r.packages.importr("utils")
package_name = "fGarch"
rlib.utils.install_packages(package_name)
除了最后的警告外,安装工作大多顺利:
/home/vdesai/anaconda/lib/python2.7/site-packages/rpy2/robjects/packages.py:216: UserWarning: Conflict when converting R symbol in the package "tools" to a Python symbol (package.dependencies -> package_dependencies while there is already package_dependencies)
warn(msg)
当我尝试加载包时:
%R library(fGarch)
我收到以下错误:
Error in library(fGarch) : there is no package called ‘fGarch’
In addition: Warning messages:
1: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, :
installation of package ‘MASS’ had non-zero exit status
2: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, :
installation of package ‘fBasics’ had non-zero exit status
3: In (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, :
installation of package ‘fGarch’ had non-zero exit status
Error in library(fGarch) : there is no package called ‘fGarch’
请注意,使用Rstudio中的此包会带来任何困难。有人可以帮忙吗?
答案 0 :(得分:1)
我找到了以下问题的答案。主要思想是1)安装anaconda,它提供了一个很好的python发行版2)通过运行如下命令来安装R通过conda:" conda install --channel https://conda.binstar.org/r r" 3)通过运行" conda install --channel https://conda.binstar.org/r rpy2"来安装rpy2。
现在,如果您尝试从ipython notebook安装fGarch,我以前在安装依赖项MASS时遇到错误。但是这些依赖项在conda channel r中作为包提供,我们可以使用命令安装它们: conda install --channel https://conda.binstar.org/r r-mass conda install --channel https://conda.binstar.org/r r-fbasics 然后,您应该能够从ipython notebook安装fGarch。
这种方法的好处是如果事情没有按计划进行,你总是可以删除包目录或整个anaconda目录。所以很容易实验。