Set working directory to the path of current script

set_wd(dir = NULL)

Arguments

dir

NULL (default) or a character string specifying the working directory.

If NULL, set working directory to the path of the current R script.

See also

Examples

if (FALSE) {
set_wd()  # set working directory to the path of the current R script

set_wd("D:/")  # "\" is not allowed, you should use "/"

set_wd("../")  # set working directory to the parent directory
}