j1897
j1897

Reputation: 1557

Error during build and reload in R

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.

Upvotes: 0

Views: 2274

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368181

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.

Upvotes: 3

Related Questions