Error during build and reload in R

可紊 提交于 2019-12-12 05:29:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!