Initialize the R environment with envsetup
Usage
init(project = getwd(), config_path = NULL, create_paths = NULL)
Arguments
- project
Character. The path to the project directory. Defaults to the current working directory.
- config_path
Character. The path of the config file. Defaults to NULL.
- create_paths
Logical indicating if missing paths should be created. Defaults to NULL.
Examples
tmpdir <- tempdir()
print(tmpdir)
#> [1] "/tmp/RtmpKPwpGu"
# account for windows
if (Sys.info()['sysname'] == "Windows") {
tmpdir <- gsub("\\", "\\\\", tmpdir, fixed = TRUE)
}
# Create an example config file\
hierarchy <- paste0("default:
paths:
data: !expr list(
DEV = file.path('",tmpdir,"', 'demo', 'DEV', 'username', 'project1', 'data'),
PROD = file.path('",tmpdir,"', 'demo', 'PROD', 'project1', 'data'))
output: !expr list(
DEV = file.path('",tmpdir,"', 'demo', 'DEV', 'username', 'project1', 'output'),
PROD = file.path('",tmpdir,"', 'demo', 'PROD', 'project1', 'output'))
programs: !expr list(
DEV = file.path('",tmpdir,"', 'demo', 'DEV', 'username', 'project1', 'programs'),
PROD = file.path('",tmpdir,"', 'demo', 'PROD', 'project1', 'programs'))")
writeLines(hierarchy, file.path(tmpdir, "hierarchy.yml"))
init(project = tmpdir,
config_path = file.path(tmpdir, "hierarchy.yml"),
create_paths = TRUE)
#> ✔ Configuration file found!
#> ✔ .Rprofile created
#> ✔ Directories built
#> /tmp/RtmpKPwpGu/demo/
#> ├── DEV
#> │ └── username
#> │ └── project1
#> │ ├── data
#> │ ├── functions
#> │ ├── output
#> │ └── programs
#> └── PROD
#> └── project1
#> ├── data
#> ├── functions
#> ├── output
#> └── programs
#> ✔ envsetup initialization complete