-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload_system_variables.R
30 lines (25 loc) · 1 KB
/
load_system_variables.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## R code voor Student Analytics Vrije Universiteit Amsterdam
## Copyright 2023 VU
## Web Page: http://www.vu.nl
## Contact: vu-analytics@vu.nl
##
##
## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Function to set all environment variables
set_all_envs <- function(var.name, var.value) {
args = list(var.value)
names(args) = var.name
do.call(Sys.setenv, args)
}
##' *INFO*: The RENVIRON_PATH is set in the .Renviron file
##' TO add it there run the following code:
##' usethis::edit_r_environ()
##' and add the following line:
##' RENVIRON_PATH = "path/to/your/file.xlsx"
to_set <- readxl::read_xlsx(Sys.getenv("RENVIRON_PATH"))
## Set systemvariables inR
purrr::pmap(list(to_set$variable, to_set$value), set_all_envs)
## +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## CLEAR ####
## +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
clear_script_objects()