diff --git a/R/processData.R b/R/processData.R index 90001cc..4d9c262 100644 --- a/R/processData.R +++ b/R/processData.R @@ -274,16 +274,19 @@ DataPackageR <- function(arg = NULL, deps = TRUE) { assert_that(file.exists(r_files[i]), msg = paste0("File: ",r_files[i]," does not exist!")) lines <- readLines(r_files[i]) - lines <- c("---", + # do we likely have a yaml header? If not, add one. + if (lines[1] != "---") { + lines <- c("---", paste0("title: ",basename(r_files[i])), paste0("author: ", Sys.info()["user"]), paste0("date: ", Sys.Date()), "---", "", lines) - con <- file(r_files[i]) - writeLines(lines, con = con, sep = "\n") - close(con) + con <- file(r_files[i]) + writeLines(lines, con = con, sep = "\n") + close(con) + } } rmarkdown::render( input = r_files[i], envir = dataenv, diff --git a/inst/extdata/tests/rfileTest.R b/inst/extdata/tests/rfileTest.R index 1d699dd..8bd45f4 100644 --- a/inst/extdata/tests/rfileTest.R +++ b/inst/extdata/tests/rfileTest.R @@ -1 +1,6 @@ +#' --- +#' title: Sample report from R script +#' author: Greg Finak +#' date: August 1, 2018 +#' --- data <- runif(100) \ No newline at end of file diff --git a/vignettes/usingDataPackageR.Rmd b/vignettes/usingDataPackageR.Rmd index 9f6ecd6..10bf2b8 100644 --- a/vignettes/usingDataPackageR.Rmd +++ b/vignettes/usingDataPackageR.Rmd @@ -144,6 +144,23 @@ Similarly: Raw data sets that are stored externally (outside the data package source tree) can be constructed relative to the `project_path()`. +### YAML header metadata for R files and Rmd files. + +If your processing scripts are Rmd files, the usual yaml header for rmarkdown documents should be present. + +If you have Rmd files, you can still include a yaml header, but it should be commented with `#'` and it should be at the top of your R file. For example, a test R file in the DataPackageR package looks as follows: + +``` +#'--- +#'title: Sample report from R script +#'author: Greg Finak +#'date: August 1, 2018 +#'--- +data <- runif(100) +``` + +This will be converted to an Rmd file with a proper yaml header, which will then be turned into a vignette and properly indexed in the built package. + ## Build the data package. diff --git a/vignettes/usingDataPackageR.html b/vignettes/usingDataPackageR.html index c54f6c6..324405a 100644 --- a/vignettes/usingDataPackageR.html +++ b/vignettes/usingDataPackageR.html @@ -291,6 +291,7 @@
The two main pieces of information in the configuration are a list of the files to be processed and the data sets the package will store.
This example packages an R data set named cars_over_20
(the name was passed in to datapackage_skeleton()
). It is created by the subsetCars.Rmd
file.
The objects must be listed in the yaml configuration file. datapackage_skeleton()
ensures this is done for you automatically.
As stated in the README, in order for your processing scripts to be portable, you should not use abosolute paths to files. DataPackageR provides an API to point to the data package root directory and the inst/extdata
and data
subdirectories. These are useful for constructing portable paths in your code to read files from these locations.
For example: to construct a path to a file named “mydata.csv” located in inst/extdata
in your data package source tree:
DataPackageR::project_extdata_path("mydata.csv")
in your R
or Rmd
file. This would return: e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20/inst/extdata/mydata.csvDataPackageR::project_extdata_path("mydata.csv")
in your R
or Rmd
file. This would return: e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20/inst/extdata/mydata.csvSimilarly:
DataPackageR::project_path()
constructs a path to the data package root directory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20)DataPackageR::project_data_path()
constructs a path to the data package data
subdirectory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20/data)DataPackageR::project_path()
constructs a path to the data package root directory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20)DataPackageR::project_data_path()
constructs a path to the data package data
subdirectory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20/data)Raw data sets that are stored externally (outside the data package source tree) can be constructed relative to the project_path()
.
If your processing scripts are Rmd files, the usual yaml header for rmarkdown documents should be present.
+If you have Rmd files, you can still include a yaml header, but it should be commented with #'
and it should be at the top of your R file. For example, a test R file in the DataPackageR package looks as follows:
#'---
+#'title: Sample report from R script
+#'author: Greg Finak
+#'date: August 1, 2018
+#'---
+data <- runif(100)
+This will be converted to an Rmd file with a proper yaml header, which will then be turned into a vignette and properly indexed in the built package.
+Once the skeleton framework is set up,
-# Run the preprocessing code to build cars_over_20
-# and reproducibly enclose it in a package.
-DataPackageR:::package_build(file.path(tempdir(),"mtcars20"))
-INFO [2018-08-01 10:57:51] Logging to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/processing.log
-INFO [2018-08-01 10:57:51] Processing data
-INFO [2018-08-01 10:57:51] Reading yaml configuration
-INFO [2018-08-01 10:57:51] Found /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/data-raw/subsetCars.Rmd
-INFO [2018-08-01 10:57:51] Processing 1 of 1: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/data-raw/subsetCars.Rmd
-
-
-processing file: subsetCars.Rmd
-
- |
- | | 0%
- |
- |......... | 14%
- ordinary text without R code
-
-
- |
- |................... | 29%
-label: unnamed-chunk-11 (with options)
-List of 1
- $ include: logi FALSE
-
-
- |
- |............................ | 43%
- ordinary text without R code
-
-
- |
- |..................................... | 57%
-label: cars
-
- |
- |.............................................. | 71%
- ordinary text without R code
-
-
- |
- |........................................................ | 86%
-label: unnamed-chunk-12
-
- |
- |.................................................................| 100%
- ordinary text without R code
-output file: subsetCars.knit.md
-/usr/local/bin/pandoc +RTS -K512m -RTS subsetCars.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/subsetCars.html --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/rmarkdown-str1464e709802b4.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
-
-Output created: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/subsetCars.html
-INFO [2018-08-01 10:57:51] 1 required data objects created by subsetCars.Rmd
-INFO [2018-08-01 10:57:51] NEWS.md file not found, creating!
-Enter a text description of the changes for the NEWS file.
-INFO [2018-08-01 10:58:08] Saving to data
-INFO [2018-08-01 10:58:08] Copied documentation to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/R/mtcars20.R
-
-✔ Creating 'vignettes/'
-✔ Creating 'inst/doc/'
-INFO [2018-08-01 10:58:08] Done
-INFO [2018-08-01 10:58:08] DataPackageR succeeded
-INFO [2018-08-01 10:58:08] Building documentation
-First time using roxygen2. Upgrading automatically...
-Updating roxygen version in /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/DESCRIPTION
-Writing NAMESPACE
-Loading mtcars20
-Writing mtcars20.Rd
-Writing cars_over_20.Rd
-INFO [2018-08-01 10:58:08] Building package
-'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file \
- --no-environ --no-save --no-restore --quiet CMD build \
- '/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20' \
- --no-resave-data --no-manual --no-build-vignettes
-
-Reloading installed mtcars20
-Next Steps
-1. Update your package documentation.
- - Edit the documentation.R file in the package source data-raw subdirectory and update the roxygen markup.
- - Rebuild the package documentation with document() .
-2. Add your package to source control.
- - Call git init . in the package source root directory.
- - git add the package files.
- - git commit your new package.
- - Set up a github repository for your pacakge.
- - Add the github repository as a remote of your local package repository.
- - git push your local repository to gitub.
-[1] "/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20_1.0.tar.gz"
# Run the preprocessing code to build cars_over_20
+# and reproducibly enclose it in a package.
+DataPackageR:::package_build(file.path(tempdir(),"mtcars20"))
+debugging in: DataPackageR(arg = package_path, deps = deps)
+debug at /Users/gfinak/Documents/Projects/DataPackageR/R/processData.R#117: {
+ pkg_dir <- arg
+ pkg_dir <- normalizePath(pkg_dir, winslash = "/")
+ usethis::proj_set(path = pkg_dir)
+ raw_data_dir <- "data-raw"
+ target <- normalizePath(file.path(pkg_dir, raw_data_dir),
+ winslash = "/")
+ raw_data_dir <- target
+ if (!file.exists(target)) {
+ flog.fatal(paste0("Directory ", target, " doesn't exist."))
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ else {
+ logpath <- normalizePath(file.path(pkg_dir, "inst/extdata"),
+ winslash = "/")
+ logpath <- file.path(logpath, "Logfiles")
+ dir.create(logpath, recursive = TRUE, showWarnings = FALSE)
+ LOGFILE <- file.path(logpath, "processing.log")
+ flog.appender(appender.tee(LOGFILE))
+ flog.info(paste0("Logging to ", LOGFILE))
+ testme <- file.path(pkg_dir, c("R", "inst", "data", "data-raw"))
+ if (!all(utils::file_test(testme, op = "-d"))) {
+ flog.fatal(paste0("You need a valid package data strucutre.",
+ " Missing ./R ./inst ./data or", "./data-raw subdirectories."))
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ flog.info("Processing data")
+ ymlfile <- dir(path = pkg_dir, pattern = "^datapackager.yml$",
+ full.names = TRUE)
+ if (length(ymlfile) == 0) {
+ flog.fatal(paste0("Yaml configuration file not found at ",
+ pkg_dir))
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ ymlconf <- read_yaml(ymlfile)
+ if (!"configuration" %in% names(ymlconf)) {
+ flog.fatal("YAML is missing 'configuration:' entry")
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ if (!all(c("files", "objects") %in% purrr::map(ymlconf,
+ names)[["configuration"]])) {
+ flog.fatal("YAML is missing files: and objects: entries")
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ flog.info("Reading yaml configuration")
+ assert_that("configuration" %in% names(ymlconf))
+ assert_that("files" %in% names(ymlconf[["configuration"]]))
+ assert_that(!is.null(names(ymlconf[["configuration"]][["files"]])))
+ r_files <- unique(names(Filter(x = ymlconf[["configuration"]][["files"]],
+ f = function(x) x$enabled)))
+ if (length(r_files) == 0) {
+ flog.fatal("No files enabled for processing!")
+ {
+ stop("error", call. = FALSE)
+ }
+ }
+ objects_to_keep <- purrr::map(ymlconf, "objects")[["configuration"]]
+ render_root <- .get_render_root(ymlconf)
+ if (!.validate_render_root(render_root)) {
+ flog.fatal(paste0("Can't create, or render_root = ",
+ render_root, " doesn't exist"))
+ stop("error", call. = FALSE)
+ }
+ else {
+ render_root <- normalizePath(render_root, winslash = "/")
+ }
+ r_files <- file.path(raw_data_dir, r_files)
+ if (all(!file.exists(r_files))) {
+ flog.fatal(paste0("Can't find any R or Rmd files."))
+ flog.fatal(paste0(" Cant' find file: ", r_files[!file.exists(r_files)]))
+ stop("error", call. = FALSE)
+ }
+ flog.info(paste0("Found ", r_files))
+ old_data_digest <- .parse_data_digest(pkg_dir = pkg_dir)
+ description_file <- normalizePath(file.path(pkg_dir,
+ "DESCRIPTION"), winslash = "/")
+ pkg_description <- try(read.description(file = description_file),
+ silent = TRUE)
+ if (length(objects_to_keep) == 0) {
+ flog.fatal("You must specify at least one data object.")
+ {
+ stop("exiting", call. = FALSE)
+ }
+ }
+ do_documentation <- FALSE
+ can_write <- FALSE
+ ENVS <- new.env(hash = TRUE, parent = .GlobalEnv)
+ for (i in seq_along(r_files)) {
+ dataenv <- new.env(hash = TRUE, parent = .GlobalEnv)
+ if (deps)
+ assign(x = "ENVS", value = ENVS, dataenv)
+ flog.info(paste0("Processing ", i, " of ", length(r_files),
+ ": ", r_files[i], "\n"))
+ flag <- FALSE
+ .isRfile <- function(f) {
+ grepl("\\.r$", tolower(f))
+ }
+ if (flag <- .isRfile(r_files[i])) {
+ knitr::spin(r_files[i], precious = TRUE, knit = FALSE)
+ r_files[i] <- paste0(tools::file_path_sans_ext(r_files[i]),
+ ".Rmd")
+ assert_that(file.exists(r_files[i]), msg = paste0("File: ",
+ r_files[i], " does not exist!"))
+ lines <- readLines(r_files[i])
+ lines <- c("---", paste0("title: ", basename(r_files[i])),
+ paste0("author: ", Sys.info()["user"]), paste0("date: ",
+ Sys.Date()), "---", "", lines)
+ con <- file(r_files[i])
+ writeLines(lines, con = con, sep = "\n")
+ close(con)
+ }
+ rmarkdown::render(input = r_files[i], envir = dataenv,
+ output_dir = logpath, clean = TRUE, knit_root_dir = render_root)
+ object_names <- ls(dataenv)
+ flog.info(paste0(sum(objects_to_keep %in% object_names),
+ " required data objects created by ", basename(r_files[i])))
+ if (sum(objects_to_keep %in% object_names) > 0) {
+ for (o in objects_to_keep[objects_to_keep %in%
+ object_names]) {
+ assign(o, get(o, dataenv), ENVS)
+ }
+ }
+ }
+ dataenv <- ENVS
+ new_data_digest <- .digest_data_env(ls(ENVS), dataenv,
+ pkg_description)
+ if (!is.null(old_data_digest)) {
+ string_check <- .check_dataversion_string(old_data_digest,
+ new_data_digest)
+ can_write <- FALSE
+ stopifnot(!((!.compare_digests(old_data_digest, new_data_digest)) &
+ string_check$isgreater))
+ if (.compare_digests(old_data_digest, new_data_digest) &
+ string_check$isequal) {
+ can_write <- TRUE
+ flog.info(paste0("Processed data sets match ",
+ "existing data sets at version ", new_data_digest[["DataVersion"]]))
+ }
+ else if ((!.compare_digests(old_data_digest, new_data_digest)) &
+ string_check$isequal) {
+ updated_version <- .increment_data_version(pkg_description,
+ new_data_digest)
+ .update_news_md(updated_version$new_data_digest[["DataVersion"]])
+ pkg_description <- updated_version$pkg_description
+ new_data_digest <- updated_version$new_data_digest
+ can_write <- TRUE
+ flog.info(paste0("Data has been updated and DataVersion ",
+ "string incremented automatically to ", new_data_digest[["DataVersion"]]))
+ }
+ else if (.compare_digests(old_data_digest, new_data_digest) &
+ string_check$isgreater) {
+ can_write <- TRUE
+ flog.info(paste0("Data hasn't changed but the ",
+ "DataVersion has been bumped."))
+ }
+ else if (string_check$isless & .compare_digests(old_data_digest,
+ new_data_digest)) {
+ flog.info(paste0("New DataVersion is less than ",
+ "old but data are unchanged"))
+ new_data_digest <- old_data_digest
+ pkg_description[["DataVersion"]] <- new_data_digest[["DataVersion"]]
+ can_write <- TRUE
+ }
+ else if (string_check$isless & !.compare_digests(old_data_digest,
+ new_data_digest)) {
+ updated_version <- .increment_data_version(pkg_description,
+ new_data_digest)
+ .update_news_md(updated_version$new_data_digest[["DataVersion"]])
+ pkg_description <- updated_version$pkg_description
+ new_data_digest <- updated_version$new_data_digest
+ can_write <- TRUE
+ }
+ if (can_write) {
+ .save_data(new_data_digest, pkg_description,
+ ls(dataenv), dataenv, old_data_digest = old_data_digest,
+ pkg_path = pkg_dir)
+ do_documentation <- TRUE
+ }
+ }
+ else {
+ .update_news_md(new_data_digest[["DataVersion"]])
+ .save_data(new_data_digest, pkg_description, ls(dataenv),
+ dataenv, old_data_digest = NULL, pkg_path = pkg_dir)
+ do_documentation <- TRUE
+ }
+ if (do_documentation) {
+ if (!file.exists(file.path(target, "documentation.R"))) {
+ .doc_autogen(basename(pkg_dir), ds2kp = ls(dataenv),
+ env = dataenv, path = target)
+ }
+ doc_parsed <- .doc_parse(file.path(target, "documentation.R"))
+ .identify_missing_docs <- function(environment = NULL,
+ description = NULL, docs = NULL) {
+ setdiff(ls(environment), setdiff(names(docs),
+ description[["Package"]]))
+ }
+ missing_doc_for_autodoc <- .identify_missing_docs(dataenv,
+ pkg_description, doc_parsed)
+ if (length(missing_doc_for_autodoc) != 0) {
+ tmptarget <- tempdir()
+ file.info("Writing missing docs.")
+ .doc_autogen(basename(pkg_dir), ds2kp = missing_doc_for_autodoc,
+ env = dataenv, path = tmptarget, name = "missing_doc.R")
+ missing_doc <- .doc_parse(file.path(tmptarget,
+ "missing_doc.R"))
+ doc_parsed <- .doc_merge(old = doc_parsed, new = missing_doc)
+ file.info("Writing merged docs.")
+ docfile <- file(file.path(target, paste0("documentation",
+ ".R")), open = "w")
+ for (i in seq_along(doc_parsed)) {
+ writeLines(text = doc_parsed[[i]], con = docfile)
+ }
+ }
+ save_docs <- do.call(c, doc_parsed)
+ docfile <- file(file.path(pkg_dir, "R", pattern = paste0(pkg_description$Package,
+ ".R")), open = "w")
+ for (i in seq_along(save_docs)) {
+ writeLines(text = save_docs[[i]], con = docfile)
+ }
+ close(docfile)
+ flog.info(paste0("Copied documentation to ", file.path(pkg_dir,
+ "R", paste0(pkg_description$Package, ".R"))))
+ can_write <- TRUE
+ }
+ eval(expr = expression(rm(list = ls())), envir = dataenv)
+ .ppfiles_mkvignettes(dir = pkg_dir)
+ }
+ flog.info("Done")
+ return(can_write)
+}
+INFO [2018-08-01 11:19:51] Logging to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/processing.log
+INFO [2018-08-01 11:19:51] Processing data
+INFO [2018-08-01 11:19:51] Reading yaml configuration
+INFO [2018-08-01 11:19:51] Found /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/data-raw/subsetCars.Rmd
+INFO [2018-08-01 11:19:51] Processing 1 of 1: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/data-raw/subsetCars.Rmd
+
+
+processing file: subsetCars.Rmd
+
+ |
+ | | 0%
+ |
+ |......... | 14%
+ ordinary text without R code
+
+
+ |
+ |................... | 29%
+label: unnamed-chunk-11 (with options)
+List of 1
+ $ include: logi FALSE
+
+
+ |
+ |............................ | 43%
+ ordinary text without R code
+
+
+ |
+ |..................................... | 57%
+label: cars
+
+ |
+ |.............................................. | 71%
+ ordinary text without R code
+
+
+ |
+ |........................................................ | 86%
+label: unnamed-chunk-12
+
+ |
+ |.................................................................| 100%
+ ordinary text without R code
+output file: subsetCars.knit.md
+/usr/local/bin/pandoc +RTS -K512m -RTS subsetCars.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/subsetCars.html --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/rmarkdown-str14e3f42f0272c.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
+
+Output created: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/subsetCars.html
+INFO [2018-08-01 11:19:52] 1 required data objects created by subsetCars.Rmd
+INFO [2018-08-01 11:19:52] NEWS.md file not found, creating!
+Enter a text description of the changes for the NEWS file.
+INFO [2018-08-01 11:19:57] Saving to data
+INFO [2018-08-01 11:19:57] Copied documentation to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/R/mtcars20.R
+
+✔ Creating 'vignettes/'
+✔ Creating 'inst/doc/'
+INFO [2018-08-01 11:19:57] Done
+exiting from: DataPackageR(arg = package_path, deps = deps)
+INFO [2018-08-01 11:19:57] DataPackageR succeeded
+INFO [2018-08-01 11:19:57] Building documentation
+First time using roxygen2. Upgrading automatically...
+Updating roxygen version in /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/DESCRIPTION
+Writing NAMESPACE
+Loading mtcars20
+Writing mtcars20.Rd
+Writing cars_over_20.Rd
+INFO [2018-08-01 11:19:58] Building package
+'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file \
+ --no-environ --no-save --no-restore --quiet CMD build \
+ '/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20' \
+ --no-resave-data --no-manual --no-build-vignettes
+
+Reloading installed mtcars20
+Next Steps
+1. Update your package documentation.
+ - Edit the documentation.R file in the package source data-raw subdirectory and update the roxygen markup.
+ - Rebuild the package documentation with document() .
+2. Add your package to source control.
+ - Call git init . in the package source root directory.
+ - git add the package files.
+ - git commit your new package.
+ - Set up a github repository for your pacakge.
+ - Add the github repository as a remote of your local package repository.
+ - git push your local repository to gitub.
+[1] "/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20_1.0.tar.gz"
When you build a package in interactive mode, you will be prompted to input text describing the changes to your data package (one line).
@@ -572,10 +827,10 @@The processed Rd
files can be found in man
.
The autogenerated documentation source is in the documentation.R
file in data-raw
.
You should update this file to properly document your objects. Then rebuild the documentation:
-document(file.path(tempdir(),"mtcars20"))
-INFO [2018-08-01 10:58:09] Rebuilding data package documentation.
-Loading mtcars20
-[1] TRUE
document(file.path(tempdir(),"mtcars20"))
+INFO [2018-08-01 11:20:00] Rebuilding data package documentation.
+Loading mtcars20
+[1] TRUE
This is done without reprocessing the data.
When the package is installed, these will be accessible via the vignette()
API.
The vignette will detail the processing performed by the subsetCars.Rmd
processing script.
The data set documentation will be accessible via ?cars_over_20
, and the data sets via data()
.
# Let's use the package we just created.
-install.packages(file.path(tempdir(),"mtcars20_1.0.tar.gz"), type = "source", repos = NULL)
-if(!"package:mtcars20"%in%search())
- attachNamespace('mtcars20') #use library() in your code
-data("cars_over_20") # load the data
-
-cars_over_20 # now we can use it.
- speed dist
-44 22 66
-45 23 54
-46 24 70
-47 24 92
-48 24 93
-49 24 120
-50 25 85
-?cars_over_20 # See the documentation you wrote in data-raw/documentation.R.
-
-vignettes <- vignette(package = "mtcars20")
-vignettes$results
- Package
-Topic "mtcars20"
- LibPath
-Topic "/Library/Frameworks/R.framework/Versions/3.5/Resources/library"
- Item Title
-Topic "subsetCars" "A Test Document for DataPackageR (source, html)"
# Let's use the package we just created.
+install.packages(file.path(tempdir(),"mtcars20_1.0.tar.gz"), type = "source", repos = NULL)
+if(!"package:mtcars20"%in%search())
+ attachNamespace('mtcars20') #use library() in your code
+data("cars_over_20") # load the data
+
+cars_over_20 # now we can use it.
+ speed dist
+44 22 66
+45 23 54
+46 24 70
+47 24 92
+48 24 93
+49 24 120
+50 25 85
+?cars_over_20 # See the documentation you wrote in data-raw/documentation.R.
+
+vignettes <- vignette(package = "mtcars20")
+vignettes$results
+ Package
+Topic "mtcars20"
+ LibPath
+Topic "/Library/Frameworks/R.framework/Versions/3.5/Resources/library"
+ Item Title
+Topic "subsetCars" "A Test Document for DataPackageR (source, html)"
Your downstream data analysis can depend on a specific version of the data in your data package by tesing the DataVersion string in the DESCRIPTION file.
We provide an API for this:
-# We can easily check the version of the data
-DataPackageR::data_version("mtcars20")
-[1] '0.1.0'
-
-# You can use an assert to check the data version in reports and
-# analyses that use the packaged data.
-assert_data_version(data_package_name = "mtcars20",
- version_string = "0.1.0",
- acceptable = "equal") #If this fails, execution stops
- #and provides an informative error.
# We can easily check the version of the data
+DataPackageR::data_version("mtcars20")
+[1] '0.1.0'
+
+# You can use an assert to check the data version in reports and
+# analyses that use the packaged data.
+assert_data_version(data_package_name = "mtcars20",
+ version_string = "0.1.0",
+ acceptable = "equal") #If this fails, execution stops
+ #and provides an informative error.
You can migrate an old package by constructing such a config file using the construct_yml_config()
API.
# assume I have file1.Rmd and file2.R located in /data-raw,
-# and these create 'object1' and 'object2' respectively.
-configuration:
- files:
- file1.Rmd:
- enabled: yes
- file2.R:
- enabled: yes
- objects:
- - object1
- - object2
- render_root:
- tmp: '256621'
# assume I have file1.Rmd and file2.R located in /data-raw,
+# and these create 'object1' and 'object2' respectively.
+configuration:
+ files:
+ file1.Rmd:
+ enabled: yes
+ file2.R:
+ enabled: yes
+ objects:
+ - object1
+ - object2
+ render_root:
+ tmp: '560209'
config
is a newly constructed yaml configuration object. It can be written to the package directory:
path_to_package <- tempdir() #e.g., if tempdir() was the root of our package.
-yml_write(config, path = path_to_package)
path_to_package <- tempdir() #e.g., if tempdir() was the root of our package.
+yml_write(config, path = path_to_package)
Now the package at path_to_package
will build with version 1.12.0 or greater.
For example:
# read 'myfile.csv' from inst/extdata relative to data-raw where the Rmd is rendered.
-read.csv(file.path("../inst/extdata","myfile.csv"))
# read 'myfile.csv' from inst/extdata relative to data-raw where the Rmd is rendered.
+read.csv(file.path("../inst/extdata","myfile.csv"))
Now Rmd
and R
scripts are processed in render_root
defined in the yaml config.
To read a raw data set we can get the path to the package source directory using an API call:
# DataPackageR::project_extdata_path() returns the path to the data package inst/extdata subdirectory directory.
-# DataPackageR::project_path() returns the path to the data package root directory.
-# DataPackageR::project_data_path() returns the path to the data package data subdirectory directory.
-read.csv(
- DataPackageR::project_extdata_path("myfile.csv")
- )
# DataPackageR::project_extdata_path() returns the path to the data package inst/extdata subdirectory directory.
+# DataPackageR::project_path() returns the path to the data package root directory.
+# DataPackageR::project_data_path() returns the path to the data package data subdirectory directory.
+read.csv(
+ DataPackageR::project_extdata_path("myfile.csv")
+ )
We can also perform partial builds of a subset of files in a package by toggling the enabled
key in the config file.
This can be done with the following API:
-config <- yml_disable_compile(config,filenames = "file2.R")
-yml_write(config, path = path_to_package) # write modified yml to the package.
-configuration:
- files:
- file1.Rmd:
- enabled: yes
- file2.R:
- enabled: no
- objects:
- - object1
- - object2
- render_root:
- tmp: '256621'
config <- yml_disable_compile(config,filenames = "file2.R")
+yml_write(config, path = path_to_package) # write modified yml to the package.
+configuration:
+ files:
+ file1.Rmd:
+ enabled: yes
+ file2.R:
+ enabled: no
+ objects:
+ - object1
+ - object2
+ render_root:
+ tmp: '560209'
Note that the modified configuration needs to be written back to the package source directory in order for the changes to take effect.
The consequence of toggling a file to enable: no
is that it will be skipped when the package is rebuilt, but the data will still be retained in the package, and the documentation will not be altered.
This is useful in situations where we have multiple data sets, and want to re-run one script to update a specific data set, but not the other scripts because they may be too time consuming, for example.
diff --git a/vignettes/usingDataPackageR.md b/vignettes/usingDataPackageR.md index 573afdf..cb2fc3c 100644 --- a/vignettes/usingDataPackageR.md +++ b/vignettes/usingDataPackageR.md @@ -113,7 +113,7 @@ configuration: enabled: yes objects: cars_over_20 render_root: - tmp: '787563' + tmp: '445902' ``` The two main pieces of information in the configuration are a list of the files to be processed and the data sets the package will store. @@ -144,15 +144,32 @@ These are useful for constructing portable paths in your code to read files from For example: to construct a path to a file named "mydata.csv" located in `inst/extdata` in your data package source tree: -- use `DataPackageR::project_extdata_path("mydata.csv")` in your `R` or `Rmd` file. This would return: e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20/inst/extdata/mydata.csv +- use `DataPackageR::project_extdata_path("mydata.csv")` in your `R` or `Rmd` file. This would return: e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20/inst/extdata/mydata.csv Similarly: -- `DataPackageR::project_path()` constructs a path to the data package root directory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20) -- `DataPackageR::project_data_path()` constructs a path to the data package `data` subdirectory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/mtcars20/data) +- `DataPackageR::project_path()` constructs a path to the data package root directory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20) +- `DataPackageR::project_data_path()` constructs a path to the data package `data` subdirectory. (e.g., /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/mtcars20/data) Raw data sets that are stored externally (outside the data package source tree) can be constructed relative to the `project_path()`. +### YAML header metadata for R files and Rmd files. + +If your processing scripts are Rmd files, the usual yaml header for rmarkdown documents should be present. + +If you have Rmd files, you can still include a yaml header, but it should be commented with `#'` and it should be at the top of your R file. For example, a test R file in the DataPackageR package looks as follows: + +``` +#'--- +#'title: Sample report from R script +#'author: Greg Finak +#'date: August 1, 2018 +#'--- +data <- runif(100) +``` + +This will be converted to an Rmd file with a proper yaml header, which will then be turned into a vignette and properly indexed in the built package. + ## Build the data package. @@ -163,11 +180,252 @@ Once the skeleton framework is set up, # Run the preprocessing code to build cars_over_20 # and reproducibly enclose it in a package. DataPackageR:::package_build(file.path(tempdir(),"mtcars20")) -INFO [2018-08-01 10:57:51] Logging to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/processing.log -INFO [2018-08-01 10:57:51] Processing data -INFO [2018-08-01 10:57:51] Reading yaml configuration -INFO [2018-08-01 10:57:51] Found /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/data-raw/subsetCars.Rmd -INFO [2018-08-01 10:57:51] Processing 1 of 1: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/data-raw/subsetCars.Rmd +debugging in: DataPackageR(arg = package_path, deps = deps) +debug at /Users/gfinak/Documents/Projects/DataPackageR/R/processData.R#117: { + pkg_dir <- arg + pkg_dir <- normalizePath(pkg_dir, winslash = "/") + usethis::proj_set(path = pkg_dir) + raw_data_dir <- "data-raw" + target <- normalizePath(file.path(pkg_dir, raw_data_dir), + winslash = "/") + raw_data_dir <- target + if (!file.exists(target)) { + flog.fatal(paste0("Directory ", target, " doesn't exist.")) + { + stop("exiting", call. = FALSE) + } + } + else { + logpath <- normalizePath(file.path(pkg_dir, "inst/extdata"), + winslash = "/") + logpath <- file.path(logpath, "Logfiles") + dir.create(logpath, recursive = TRUE, showWarnings = FALSE) + LOGFILE <- file.path(logpath, "processing.log") + flog.appender(appender.tee(LOGFILE)) + flog.info(paste0("Logging to ", LOGFILE)) + testme <- file.path(pkg_dir, c("R", "inst", "data", "data-raw")) + if (!all(utils::file_test(testme, op = "-d"))) { + flog.fatal(paste0("You need a valid package data strucutre.", + " Missing ./R ./inst ./data or", "./data-raw subdirectories.")) + { + stop("exiting", call. = FALSE) + } + } + flog.info("Processing data") + ymlfile <- dir(path = pkg_dir, pattern = "^datapackager.yml$", + full.names = TRUE) + if (length(ymlfile) == 0) { + flog.fatal(paste0("Yaml configuration file not found at ", + pkg_dir)) + { + stop("exiting", call. = FALSE) + } + } + ymlconf <- read_yaml(ymlfile) + if (!"configuration" %in% names(ymlconf)) { + flog.fatal("YAML is missing 'configuration:' entry") + { + stop("exiting", call. = FALSE) + } + } + if (!all(c("files", "objects") %in% purrr::map(ymlconf, + names)[["configuration"]])) { + flog.fatal("YAML is missing files: and objects: entries") + { + stop("exiting", call. = FALSE) + } + } + flog.info("Reading yaml configuration") + assert_that("configuration" %in% names(ymlconf)) + assert_that("files" %in% names(ymlconf[["configuration"]])) + assert_that(!is.null(names(ymlconf[["configuration"]][["files"]]))) + r_files <- unique(names(Filter(x = ymlconf[["configuration"]][["files"]], + f = function(x) x$enabled))) + if (length(r_files) == 0) { + flog.fatal("No files enabled for processing!") + { + stop("error", call. = FALSE) + } + } + objects_to_keep <- purrr::map(ymlconf, "objects")[["configuration"]] + render_root <- .get_render_root(ymlconf) + if (!.validate_render_root(render_root)) { + flog.fatal(paste0("Can't create, or render_root = ", + render_root, " doesn't exist")) + stop("error", call. = FALSE) + } + else { + render_root <- normalizePath(render_root, winslash = "/") + } + r_files <- file.path(raw_data_dir, r_files) + if (all(!file.exists(r_files))) { + flog.fatal(paste0("Can't find any R or Rmd files.")) + flog.fatal(paste0(" Cant' find file: ", r_files[!file.exists(r_files)])) + stop("error", call. = FALSE) + } + flog.info(paste0("Found ", r_files)) + old_data_digest <- .parse_data_digest(pkg_dir = pkg_dir) + description_file <- normalizePath(file.path(pkg_dir, + "DESCRIPTION"), winslash = "/") + pkg_description <- try(read.description(file = description_file), + silent = TRUE) + if (length(objects_to_keep) == 0) { + flog.fatal("You must specify at least one data object.") + { + stop("exiting", call. = FALSE) + } + } + do_documentation <- FALSE + can_write <- FALSE + ENVS <- new.env(hash = TRUE, parent = .GlobalEnv) + for (i in seq_along(r_files)) { + dataenv <- new.env(hash = TRUE, parent = .GlobalEnv) + if (deps) + assign(x = "ENVS", value = ENVS, dataenv) + flog.info(paste0("Processing ", i, " of ", length(r_files), + ": ", r_files[i], "\n")) + flag <- FALSE + .isRfile <- function(f) { + grepl("\\.r$", tolower(f)) + } + if (flag <- .isRfile(r_files[i])) { + knitr::spin(r_files[i], precious = TRUE, knit = FALSE) + r_files[i] <- paste0(tools::file_path_sans_ext(r_files[i]), + ".Rmd") + assert_that(file.exists(r_files[i]), msg = paste0("File: ", + r_files[i], " does not exist!")) + lines <- readLines(r_files[i]) + lines <- c("---", paste0("title: ", basename(r_files[i])), + paste0("author: ", Sys.info()["user"]), paste0("date: ", + Sys.Date()), "---", "", lines) + con <- file(r_files[i]) + writeLines(lines, con = con, sep = "\n") + close(con) + } + rmarkdown::render(input = r_files[i], envir = dataenv, + output_dir = logpath, clean = TRUE, knit_root_dir = render_root) + object_names <- ls(dataenv) + flog.info(paste0(sum(objects_to_keep %in% object_names), + " required data objects created by ", basename(r_files[i]))) + if (sum(objects_to_keep %in% object_names) > 0) { + for (o in objects_to_keep[objects_to_keep %in% + object_names]) { + assign(o, get(o, dataenv), ENVS) + } + } + } + dataenv <- ENVS + new_data_digest <- .digest_data_env(ls(ENVS), dataenv, + pkg_description) + if (!is.null(old_data_digest)) { + string_check <- .check_dataversion_string(old_data_digest, + new_data_digest) + can_write <- FALSE + stopifnot(!((!.compare_digests(old_data_digest, new_data_digest)) & + string_check$isgreater)) + if (.compare_digests(old_data_digest, new_data_digest) & + string_check$isequal) { + can_write <- TRUE + flog.info(paste0("Processed data sets match ", + "existing data sets at version ", new_data_digest[["DataVersion"]])) + } + else if ((!.compare_digests(old_data_digest, new_data_digest)) & + string_check$isequal) { + updated_version <- .increment_data_version(pkg_description, + new_data_digest) + .update_news_md(updated_version$new_data_digest[["DataVersion"]]) + pkg_description <- updated_version$pkg_description + new_data_digest <- updated_version$new_data_digest + can_write <- TRUE + flog.info(paste0("Data has been updated and DataVersion ", + "string incremented automatically to ", new_data_digest[["DataVersion"]])) + } + else if (.compare_digests(old_data_digest, new_data_digest) & + string_check$isgreater) { + can_write <- TRUE + flog.info(paste0("Data hasn't changed but the ", + "DataVersion has been bumped.")) + } + else if (string_check$isless & .compare_digests(old_data_digest, + new_data_digest)) { + flog.info(paste0("New DataVersion is less than ", + "old but data are unchanged")) + new_data_digest <- old_data_digest + pkg_description[["DataVersion"]] <- new_data_digest[["DataVersion"]] + can_write <- TRUE + } + else if (string_check$isless & !.compare_digests(old_data_digest, + new_data_digest)) { + updated_version <- .increment_data_version(pkg_description, + new_data_digest) + .update_news_md(updated_version$new_data_digest[["DataVersion"]]) + pkg_description <- updated_version$pkg_description + new_data_digest <- updated_version$new_data_digest + can_write <- TRUE + } + if (can_write) { + .save_data(new_data_digest, pkg_description, + ls(dataenv), dataenv, old_data_digest = old_data_digest, + pkg_path = pkg_dir) + do_documentation <- TRUE + } + } + else { + .update_news_md(new_data_digest[["DataVersion"]]) + .save_data(new_data_digest, pkg_description, ls(dataenv), + dataenv, old_data_digest = NULL, pkg_path = pkg_dir) + do_documentation <- TRUE + } + if (do_documentation) { + if (!file.exists(file.path(target, "documentation.R"))) { + .doc_autogen(basename(pkg_dir), ds2kp = ls(dataenv), + env = dataenv, path = target) + } + doc_parsed <- .doc_parse(file.path(target, "documentation.R")) + .identify_missing_docs <- function(environment = NULL, + description = NULL, docs = NULL) { + setdiff(ls(environment), setdiff(names(docs), + description[["Package"]])) + } + missing_doc_for_autodoc <- .identify_missing_docs(dataenv, + pkg_description, doc_parsed) + if (length(missing_doc_for_autodoc) != 0) { + tmptarget <- tempdir() + file.info("Writing missing docs.") + .doc_autogen(basename(pkg_dir), ds2kp = missing_doc_for_autodoc, + env = dataenv, path = tmptarget, name = "missing_doc.R") + missing_doc <- .doc_parse(file.path(tmptarget, + "missing_doc.R")) + doc_parsed <- .doc_merge(old = doc_parsed, new = missing_doc) + file.info("Writing merged docs.") + docfile <- file(file.path(target, paste0("documentation", + ".R")), open = "w") + for (i in seq_along(doc_parsed)) { + writeLines(text = doc_parsed[[i]], con = docfile) + } + } + save_docs <- do.call(c, doc_parsed) + docfile <- file(file.path(pkg_dir, "R", pattern = paste0(pkg_description$Package, + ".R")), open = "w") + for (i in seq_along(save_docs)) { + writeLines(text = save_docs[[i]], con = docfile) + } + close(docfile) + flog.info(paste0("Copied documentation to ", file.path(pkg_dir, + "R", paste0(pkg_description$Package, ".R")))) + can_write <- TRUE + } + eval(expr = expression(rm(list = ls())), envir = dataenv) + .ppfiles_mkvignettes(dir = pkg_dir) + } + flog.info("Done") + return(can_write) +} +INFO [2018-08-01 11:19:51] Logging to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/processing.log +INFO [2018-08-01 11:19:51] Processing data +INFO [2018-08-01 11:19:51] Reading yaml configuration +INFO [2018-08-01 11:19:51] Found /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/data-raw/subsetCars.Rmd +INFO [2018-08-01 11:19:51] Processing 1 of 1: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/data-raw/subsetCars.Rmd processing file: subsetCars.Rmd @@ -192,30 +450,31 @@ label: unnamed-chunk-12 | |.................................................................| 100% ordinary text without R code output file: subsetCars.knit.md -/usr/local/bin/pandoc +RTS -K512m -RTS subsetCars.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/subsetCars.html --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpKYGfGp/rmarkdown-str1464e709802b4.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' +/usr/local/bin/pandoc +RTS -K512m -RTS subsetCars.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/subsetCars.html --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T//RtmpHrauiV/rmarkdown-str14e3f42f0272c.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' -Output created: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/inst/extdata/Logfiles/subsetCars.html -INFO [2018-08-01 10:57:51] 1 required data objects created by subsetCars.Rmd -INFO [2018-08-01 10:57:51] NEWS.md file not found, creating! +Output created: /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/inst/extdata/Logfiles/subsetCars.html +INFO [2018-08-01 11:19:52] 1 required data objects created by subsetCars.Rmd +INFO [2018-08-01 11:19:52] NEWS.md file not found, creating! Enter a text description of the changes for the NEWS file. -INFO [2018-08-01 10:58:08] Saving to data -INFO [2018-08-01 10:58:08] Copied documentation to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/R/mtcars20.R +INFO [2018-08-01 11:19:57] Saving to data +INFO [2018-08-01 11:19:57] Copied documentation to /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/R/mtcars20.R ✔ Creating 'vignettes/' ✔ Creating 'inst/doc/' -INFO [2018-08-01 10:58:08] Done -INFO [2018-08-01 10:58:08] DataPackageR succeeded -INFO [2018-08-01 10:58:08] Building documentation +INFO [2018-08-01 11:19:57] Done +exiting from: DataPackageR(arg = package_path, deps = deps) +INFO [2018-08-01 11:19:57] DataPackageR succeeded +INFO [2018-08-01 11:19:57] Building documentation First time using roxygen2. Upgrading automatically... -Updating roxygen version in /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20/DESCRIPTION +Updating roxygen version in /private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20/DESCRIPTION Writing NAMESPACE Loading mtcars20 Writing mtcars20.Rd Writing cars_over_20.Rd -INFO [2018-08-01 10:58:08] Building package +INFO [2018-08-01 11:19:58] Building package '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file \ --no-environ --no-save --no-restore --quiet CMD build \ - '/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20' \ + '/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20' \ --no-resave-data --no-manual --no-build-vignettes Reloading installed mtcars20 @@ -230,7 +489,7 @@ Next Steps - Set up a github repository for your pacakge. - Add the github repository as a remote of your local package repository. - git push your local repository to gitub. -[1] "/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpKYGfGp/mtcars20_1.0.tar.gz" +[1] "/private/var/folders/jh/x0h3v3pd4dd497g3gtzsm8500000gn/T/RtmpHrauiV/mtcars20_1.0.tar.gz" ``` ### Documenting your data set changes in NEWS.md @@ -314,7 +573,7 @@ You should update this file to properly document your objects. Then rebuild the ```r document(file.path(tempdir(),"mtcars20")) -INFO [2018-08-01 10:58:09] Rebuilding data package documentation. +INFO [2018-08-01 11:20:00] Rebuilding data package documentation. Loading mtcars20 [1] TRUE ``` @@ -414,7 +673,7 @@ configuration: - object1 - object2 render_root: - tmp: '256621' + tmp: '560209' ``` `config` is a newly constructed yaml configuration object. It can be written to the package directory: @@ -477,7 +736,7 @@ configuration: - object1 - object2 render_root: - tmp: '256621' + tmp: '560209' ``` Note that the modified configuration needs to be written back to the package source directory in order for the