当使用“R CMD INSTALL”时如何安装依赖关系安装R包? [英] How to install dependencies when using "R CMD INSTALL" to install R packages?

查看:5128
本文介绍了当使用“R CMD INSTALL”时如何安装依赖关系安装R包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发我的第一个R包(使用R 2.13,Ubuntu 10.10)。让我们称之为 foo ,假设R /目录中的代码以库(bar)行开头,其中是现有的包,在CRAN中,其中 foo 依赖。我的DESCRIPTION文件包含以下行:

 取决于:bar 

当包 foo 准备进行测试时,我在本地安装:

  R CMD INSTALL foo_1.0.tar.gz 

但是,如果 bar 未安装,我看到:

 错误:依赖关系bar不可用于包'foo'

显然,如果我使用安装从CRAN安装了我的 foo .packages(), bar 将同时安装。所以我的问题是:如果需要,当我使用R CMD INSTALL安装我的软件包 foo 时,如何安装CRAN软件包?这是配置脚本的工作吗?

解决方案

实际上,重新阅读R扩展指南,并不是说R CMD INSTALL将获得CRAN的依赖关系。 R中的install.packages()方法将会做到这一点,但是乍一看,我不认为R CMD INSTALL是这样的。



可以使用install.packages从.tar.gz安装,但是您必须设置repos = NULL,然后适用:

 依赖关系:逻辑指示还要安装这些软件包依赖于/ suggest / import的卸载软件包
(等等)
递归)。如果repos = NULL,则不使用。

我怀疑要做的是从DESCRIPTION文件中获取依赖项,然后运行R和当您在干净的环境中测试您的构建时,请对其进行一次install.packages()。


I'm developing my first R package (using R 2.13, Ubuntu 10.10). Let's call it foo and let's say that the code in the R/ directory begins with the line library(bar), where bar is an existing package, in CRAN, on which foo depends. My DESCRIPTION file contains the line:

Depends: bar

When package foo is ready for testing, I install it locally using:

R CMD INSTALL foo_1.0.tar.gz

However, if bar is not installed, I see:

ERROR: dependency ‘bar’ is not available for package ‘foo’

Obviously, if my foo were installed from CRAN using install.packages(), bar would be installed at the same time. So my question is: how can I ensure that CRAN package bar is installed, if required, when I install my package foo using R CMD INSTALL? Is this a job for a configuration script?

解决方案

Actually, re-reading the R extensions guide, it doesn't say that R CMD INSTALL will get dependencies from CRAN. The install.packages() method from within R will do that, but at first glance I don't think R CMD INSTALL does.

You can use install.packages to install from a .tar.gz, but you have to set repos=NULL, and then this applies:

 dependencies: logical indicating to also install uninstalled packages
          on which these packages depend/suggest/import (and so on
          recursively).  Not used if repos = NULL.

I suspect the thing to do is to get the dependencies out of the DESCRIPTION file and then run R and do an install.packages() on those when you are testing your build in a clean environment.

这篇关于当使用“R CMD INSTALL”时如何安装依赖关系安装R包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆