Skip to content

Commit

Permalink
Implement use_data_raw().
Browse files Browse the repository at this point in the history
Closes #541
  • Loading branch information
hadley committed Aug 13, 2014
1 parent 71ff749 commit 81701d8
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export(submit_cran)
export(test)
export(unload)
export(use_data)
export(use_data_raw)
export(use_knitr)
export(use_package_doc)
export(use_rcpp)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* New `use_data()` makes it easy to include data in a package, either
in `data/` (for exported datasets) or in `R/sysdata.rda` (for internal
data). (#542)

* New `use_data_raw()` to create `data-raw/` directory for reproducible
generation of `data/` files (#541).

* New `use_rcpp()` sets up a package to use Rcpp.

Expand Down
22 changes: 22 additions & 0 deletions R/infrastructure.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,25 @@ use_data <- function(..., pkg = ".", internal = FALSE, overwrite = FALSE,
invisible()
}

#' Use \code{data-raw} to compute package datasets.
#'
#' @param pkg Package where to create \code{data-raw}. Defaults to package in
#' working directory.
#' @export
#' @family infrastructure
use_data_raw <- function(pkg = ".") {
pkg <- as.package(pkg)

path <- file.path(pkg$path, "data-raw")
if (file.exists(path)) {
stop("data-raw/ already exists", call. = FALSE)
}

message("Creating data-raw/")
dir.create(path)
add_build_ignore(pkg, "data-raw")

message("Next: \n",
"* Add data creation scripts in data-raw\n",
"* Use devtools::use_data() to add data to package")
}
3 changes: 2 additions & 1 deletion man/infrastructure.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Add basic travis template to a package. Also adds \code{.travis.yml} to
Adds a roxygen template for package documentation
}
\seealso{
Other infrastructure: \code{\link{use_data}}
Other infrastructure: \code{\link{use_data_raw}};
\code{\link{use_data}}
}
3 changes: 2 additions & 1 deletion man/use_data.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Other infrastructure: \code{\link{add_rstudio_project}},
\code{\link{add_travis}}, \code{\link{infrastructure}},
\code{\link{use_knitr}}, \code{\link{use_package_doc}},
\code{\link{use_rcpp}}, \code{\link{use_rstudio}},
\code{\link{use_testthat}}, \code{\link{use_travis}}
\code{\link{use_testthat}}, \code{\link{use_travis}};
\code{\link{use_data_raw}}
}

24 changes: 24 additions & 0 deletions man/use_data_raw.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{use_data_raw}
\alias{use_data_raw}
\title{Use \code{data-raw} to compute package datasets.}
\usage{
use_data_raw(pkg = ".")
}
\arguments{
\item{pkg}{Package where to create \code{data-raw}. Defaults to package in
working directory.}
}
\description{
Use \code{data-raw} to compute package datasets.
}
\seealso{
Other infrastructure: \code{\link{add_rstudio_project}},
\code{\link{add_test_infrastructure}},
\code{\link{add_travis}}, \code{\link{infrastructure}},
\code{\link{use_knitr}}, \code{\link{use_package_doc}},
\code{\link{use_rcpp}}, \code{\link{use_rstudio}},
\code{\link{use_testthat}}, \code{\link{use_travis}};
\code{\link{use_data}}
}

0 comments on commit 81701d8

Please sign in to comment.