00_setup_dir.R

# Create Organized R Project Directory ------------------------------------

# This will not overwrite any pre-existing folders with the same names in the specified directory path

if (!require(here)) install.packages("here")
library(here)

create_dir <- function(path) {
  if (!is.character(path)) stop("please input path name as string")
  
  if (!dir.exists(here(path))) dir.create(here(path))
}

create_dir("_data")
create_dir("_markdown")
create_dir("_reports")
create_dir("R")
create_dir("_result")
create_dir("_test")
create_dir("_deprecated")
create_dir("_figures")

fileCon <- file("Rproject_str.txt")
writeLines(paste0("Rproject Folder Structure \n 
This text files outlines best practices following folders are generated by the '00_setup_dir.R' script: \n
 - '_data' should contain all raw data files that should NOT be modified is any manner, only read or imported into R
 - '_result' should contain any modified data files
 - '_figures' should contain any plots or figures generated by R
 - 'R' should contain user-defined functions or helper functions
 - '_markdown' should contain all .Rmd files
 - '_reports' should contain all markdown output from the '_markdown' folder
 - '_test' acts as a sandbox for R code for testing or exploration. Nothing here should be sourced for formal use
 - '_deprecated' should contain any code that is not actively used or outdated. This should be cleaned/dumped every month
\n
More information:
Wilson G, Bryan J, Cranston K, Kitzes J, Nederbragt L, et al. (2017) Good enough practices in scientific computing. PLOS Computational Biology 13(6): e1005510. https://doi.org/10.1371/journal.pcbi.1005510
\n
Created on: ", format(Sys.time(), "%X %b %d %Y")),
           fileCon)
close(fileCon)
rm(create_dir, fileCon)
smh-ej/XploreR documentation built on May 13, 2019, 4:46 p.m.