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
.
Furthermore,
oldpackage is installed in the directory,
~/lib/R
my
.Rprofile
includes.libPaths("~/lib/R")
- hence, I can successfully load oldpackage without specifying the library location, e.g., using the command
library(oldpackage)
in R
- hence, I can successfully load oldpackage without specifying the library location, e.g., using the command
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:
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:
Why is R unable to find the package?
Can I specify the library location in the DESCRIPTION file?
Regarding question 1), it is both a FAQ and yet somewhat annoying. R CMD check
runs in vanilla mode, so it will not find user-level libraries. As I recall, setting R_LIBS="...." in the call helps, so try that.
Regarding question 2), no you cannot give a location in DESCRIPTION. Which makes sense as that file needs to work 'everywhere' whereas your location info is local to your machine.
精彩评论