Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Created March 31, 2016 18:09
Show Gist options
  • Save ZeccaLehn/00573d526ba140ca8a244e39ac0d1c1e to your computer and use it in GitHub Desktop.
Save ZeccaLehn/00573d526ba140ca8a244e39ac0d1c1e to your computer and use it in GitHub Desktop.
[R] Desktop Directory Function for Windows or Linux
# Allows for working directory to be used on Windows or Linux
projectFolder <- "YOURDESKTOPFOLDER"
if(Sys.info()['sysname'] == "Linux"){
setwd( paste0( Sys.getenv("HOME") , paste0("/Desktop/", projectFolder, "/") ) )
} else {
X <- Sys.getenv('HOME')
setwd(gsub("Documents", paste0("/Desktop/", projectFolder, "/"), X))
rm(X)
}
getwd()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment