问题
I am roxygenizing a package I am making in R.
The script is
#' HandyTools
#'
#' Check if required packages are installed or not and installs them if not
#' @param packageList - a list containing the required package names
#'
#' @examples
#' checkPackagesLibrary(c("lme4","epitools","roxygen2"))
#'
#' @export
library(devtools)
checkPackagesLibrary <- function(packagesList){
new.packages <- packagesList[!(packagesList %in% installed.packages(lib.loc="/data/legacy/user/R_Packages")[,"Package"])]
if(length(new.packages))
install.packages(new.packages, lib = "/data/legacy/user/R_Packages")
else
print("Required packages are already installed")
}
While build and reload in RStudio, the error is:
==> devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette'))
Updating HandyTools documentation
Loading HandyTools
Error: Missing name at code.R:14
In addition: Warning message:
In setup_ns_exports(pkg, export_all) :
Objects listed as exports, but not present in namespace: c
Execution halted
Exited with status 1.
Error is at line 14, which is
library(devtools)
If I comment this line, the error disappears.
回答1:
Rookie error: you are not supposed to have library()...
calls in scripts in your packages.
Use DESCRIPTION
and NAMESPACE
instead, preferably via Imports:
and importFrom()
statements.
来源:https://stackoverflow.com/questions/34743542/error-during-build-and-reload-in-r