Skip to content

Instantly share code, notes, and snippets.

@isteves
Created January 26, 2021 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isteves/d0fa4ff64e421ce8a4c50ddd420c2de3 to your computer and use it in GitHub Desktop.
Save isteves/d0fa4ff64e421ce8a4c50ddd420c2de3 to your computer and use it in GitHub Desktop.
Using glue::glue() inside of another function

Using glue inside of another function

The key is defining an environment!

test_glue <- function(cmd, e = parent.frame()) {
  crayon::red(glue::glue(cmd, .envir = e))
}

test_fxn <- function (name) {
  cat(test_glue("hello, {name}"))
}

test_fxn("Joleen")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment