R/Sroot.R

Defines functions Sroot

Documented in Sroot

#' Set root
#'
#' Automatically change root directory based on OS
#' @param Takes root directory from Sys.info
#' @keywords directory
#' @export
#' @examples
#' Sroot()

Sroot <- function()
{
  if (.Platform$OS.type == "windows") { 
    root <- paste("C:\\Users\\", Sys.info()["user"], sep= "")
  } else if (Sys.info()["sysname"] == "Darwin") {
    root <- paste("/Users/", Sys.info()["user"], sep= "") 
  } else if (.Platform$OS.type == "unix") { 
    root <- paste("/usr/", Sys.info()["user"], sep= "")
  } else {
    stop("Unknown OS")
  }
  setwd(root)
  cat("Root directory = ", getwd() )
}
NickOtis/Sroot documentation built on May 7, 2019, 6:07 p.m.