package_build: Pre-process, document and build a data package

View source: R/build.R

package_buildR Documentation

Pre-process, document and build a data package

Description

Combines the preprocessing, documentation, and build steps into one.

Usage

package_build(
  packageName = NULL,
  vignettes = FALSE,
  log = INFO,
  deps = TRUE,
  install = FALSE,
  ...
)

Arguments

packageName

character path to package source directory. Defaults to the current path when NULL.

vignettes

logical specify whether to build vignettes. Default FALSE.

log

log level INFO,WARN,DEBUG,FATAL

deps

logical should we pass data objects into subsequent scripts? Default TRUE

install

logical automatically install and load the package after building. Default FALSE

...

additional arguments passed to install.packages when install=TRUE.

Details

Note that if package_build returns an error when rendering an .Rmd internally, but that same .Rmd can be run successfully manually using rmarkdown::render, then the following code facilitates debugging. Set options(error = function(){ sink(); recover()}) before running package_build . This will enable examination of the active function calls at the time of the error, with output printed to the console rather than knitr's default sink. After debugging, evaluate options(error = NULL) to revert to default error handling. See section "22.5.3 RMarkdown" at https://adv-r.hadley.nz/debugging.html for more details.

Value

Character vector. File path of the built package.

Examples

if(rmarkdown::pandoc_available()){
f <- tempdir()
f <- file.path(f,"foo.Rmd")
con <- file(f)
writeLines("```{r}\n tbl = data.frame(1:10) \n```\n",con=con)
close(con)
pname <- basename(tempfile())
datapackage_skeleton(name=pname,
   path=tempdir(),
   force = TRUE,
   r_object_names = "tbl",
   code_files = f)

package_build(file.path(tempdir(),pname), install = FALSE)
}

ropensci/DataPackageR documentation built on April 17, 2024, 11:43 a.m.