R/make_project.R

Defines functions make_project

Documented in make_project

#' Create DCL project template
#'
#' Creates a project template with folders (data-raw, scripts, data, eda, and reports)
#' and a Makefile template.
#'
#' @param path
#' @param ...
#'
#' @export
make_project <- function(path, ...) {
  dir.create(path, recursive = TRUE, showWarnings = FALSE)

  folders <-
    c(
      `Raw data` = "data-raw",
      `Processed data` = "data",
      `Scripts` = "scripts",
      `Docs` = "docs",
      `EDA` = "eda",
      `Reports` = "reports"
    )

  for (i in 1:length(folders)) {
    dir.create(path = file.path(path, folders[[i]]), showWarnings = FALSE)
    file.create(path = file.path(path, folders[[i]], "README.md"))
    writeLines(
      text = paste("#", names(folders)[[i]]),
      con = file.path(path, folders[[i]], "README.md")
    )
  }

  file.copy(
    from = system.file("resources/Makefile", package = "dclproject"),
    to = path
  )
}
skaltman/dclproject documentation built on Nov. 5, 2019, 9:20 a.m.