I do not know but if you are interested, this may be helpful as well:
https://github.com/imanojkumar/MyFunctions1/blob/master/README.md
Or just use the below code:
source("https://raw.githubusercontent.com/imanojkumar/MyFunctions1/master/ChangeDirectory.R")
The above source file contains the below three codes:
1. Ask user to give path to directory
directory <- readline('Enter Path to Directory You want to set as
Default (use backslash e.g. "E:/MyDirectory") : ')
2. Function
myfunction <- function(directory) {
if (!is.null(directory))
setwd(directory)
}
3. Function runs in the background and sets the user defined directory as default
myfunction(directory)