简体   繁体   English

由于包依赖性导致R CMD检查错误

[英]error with R CMD check because of package dependency

Background 背景

I am creating a newpackage that depends on oldpackage , and have indicated this dependency in the file newpackage/DESCRIPTION . 我创建取决于oldpackage一个newpackage,并表示在文件这种依赖newpackage/DESCRIPTION

Furthermore, 此外,

  • oldpackage is installed in the directory, ~/lib/R oldpackage安装在目录~/lib/R

  • my .Rprofile includes .libPaths("~/lib/R") 我的.Rprofile包含.libPaths("~/lib/R")

    • hence, I can successfully load oldpackage without specifying the library location, eg, using the command library(oldpackage) in R 因此,我可以在不指定库位置的情况下成功加载oldpackage ,例如,使用R中的命令library(oldpackage)

Despite the ability to load the package without having its library specified, R CMD check newpackage gives an error indicating that it can not fine oldpackage : 尽管能够在没有指定库的情况下加载包,但是R CMD check newpackage会给出一个错误,表明它不能很好地解决oldpackage

checking whether the package can be loaded ... ERROR 
Loading required package: oldpackage
Error: package 'oldpackage' could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
  there is no package called 'oldpackage'
Execution halted


It looks like this package has a loading problem: see the messages for
    details.

Questions: 问题:

  1. Why is R unable to find the package? 为什么R无法找到包裹?

  2. Can I specify the library location in the DESCRIPTION file? 我可以在DESCRIPTION文件中指定库位置吗?

Regarding question 1), it is both a FAQ and yet somewhat annoying. 关于问题1),它既是常见问题,又有点烦人。 R CMD check runs in vanilla mode, so it will not find user-level libraries. R CMD check以vanilla模式运行,因此无法找到用户级库。 As I recall, setting R_LIBS="...." in the call helps, so try that. 我记得,在通话中设置R_LIBS =“....”有帮助,所以试试吧。

Regarding question 2), no you cannot give a location in DESCRIPTION. 关于问题2),不,你不能在DESCRIPTION中给出一个位置。 Which makes sense as that file needs to work 'everywhere' whereas your location info is local to your machine. 这有意义,因为该文件需要“随处”工作,而您的位置信息是您的机器的本地信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM