R/Rproj_init.R

Defines functions Rproj_init

Documented in Rproj_init

#' Initialize an RStudio-project
#' 
#' @description Creates an .Rproj-file within your current working directory.
#' @inheritParams project_framework
#' @note It is not possible to overwrite an existing Rproj.
#' @author Frederik Sachser
#' @export
Rproj_init <- function(project_dir){
  projname <- unlist(strsplit(project_dir, split = '/'))[length(unlist(strsplit(project_dir, split = '/')))]
  if (file.exists(paste(projname, '.Rproj', sep = '')) == TRUE) {
    stop('project already exists')
  } else {
    sink(paste0(projname, '.Rproj'))
    cat("Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
        
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
      
RnwWeave: knitr
LaTeX: Default
        
AutoAppendNewline: Yes")
sink()
  }
}
sachserf/repres documentation built on May 29, 2019, 12:21 p.m.