在R中生成和重新加载时出错



我正在对我在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)

如果我评论这一行,错误就会消失。

Rookie错误:包中的脚本中不应该有library()...调用。

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

相关内容

  • 没有找到相关文章

最新更新