在R中构建和重新加载期间出错

时间:2016-01-12 12:20:38

标签: r roxygen2 r-package

我正在为我在R中制作的包裹进行氧化。

脚本是

#' 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")
}

在RStudio中构建和重新加载时,错误是:

==> 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.

错误位于第14行,即

library(devtools)

如果我评论此行,则错误消失。

1 个答案:

答案 0 :(得分:2)

新手错误:您不应该在程序包中的脚本中进行library()...次调用。

请改为使用DESCRIPTIONNAMESPACE,最好通过Imports:importFrom()语句。