Skip to content

Instantly share code, notes, and snippets.

@JohnCoene
Last active March 12, 2019 09:03
Show Gist options
  • Select an option

  • Save JohnCoene/0e764e6a7d2b9e80481d73f5f2f9a0db to your computer and use it in GitHub Desktop.

Select an option

Save JohnCoene/0e764e6a7d2b9e80481d73f5f2f9a0db to your computer and use it in GitHub Desktop.
Environment var
library(magrittr)
db <- new.env(hash = TRUE)
define_vars <- function(...){
assign("my_vars", ..., envir = db)
}
print_vars <- function(){
print(
get("my_vars", envir = db) %>%
unlist() %>%
paste(collapse = " ")
)
}
# run
define_vars(c("hello", "world"))
print_vars()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment