R/set_prj.R

#' Set my R-Project.
#'
#' @param path Path to Project.
#' @param index Logical. If `true` then make "index.Rmd" file. This file is quite plane R Markdown file.
#' @return Make "R", "docs", "data" directories in this Project directory.
#' @examples
#' set_prj()
#' @export

set_prj <- function (path = ".", index = FALSE)
{
  dir.create(file.path(path, "R"), showWarnings = FALSE)
  dir.create(file.path(path, "docs"), showWarnings = FALSE)
  dir.create(file.path(path, "datas"), showWarnings = FALSE)
  if(index) {
    if(file.exists(file.path(path, "docs", "index.Rmd"))) {
      message("file 'index.Rmd' already exits.")
    } else {
      file.create(file.path(path, "docs", "index.Rmd"))
      cat("---", "title: ", "output: ", "---", sep = "/n", file = file.path(path, "docs","index.Rmd"))
    }
  }
  invisible(TRUE)
}
kazutan/zousan documentation built on May 20, 2019, 7:54 a.m.