R/create_project.R

Defines functions move_files create_project

Documented in create_project

move_files = function(chapter, dest) {
  ## Create chapter directory
  chapter = paste0("chapter", chapter)
  dir.create(file.path(dest, chapter), showWarnings = FALSE)
  path = system.file(chapter, package = "jrAutomate")
  fnames = list.files(path, full.names = TRUE)
  file.copy(fnames, file.path(dest, chapter))

  ## Copy vignette
  path = system.file("doc", package = "jrAutomate")
  file.copy(file.path(path, paste0(chapter, ".Rmd")), dest)
}

#' Copy files from package to script
#'
#' A simple function for copying package files to users directory.
#' @export
create_project = function() {
  dir.create("original", showWarnings = FALSE)
  dir.create("exercises", showWarnings = FALSE)
  move_files(chapter = 1, dest = "original")
  move_files(1, dest = "exercises")
  move_files(3, dest = "original")
  move_files(3, dest = "exercises")
}
jr-packages/jrAutomate documentation built on Dec. 14, 2019, 6:35 p.m.