Skip to content

Instantly share code, notes, and snippets.

@randrescastaneda
Created February 21, 2024 14:49
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 randrescastaneda/34b6eeb4639fc42f2759e814f58ac0cd to your computer and use it in GitHub Desktop.
Save randrescastaneda/34b6eeb4639fc42f2759e814f58ac0cd to your computer and use it in GitHub Desktop.
How to use with
foo <- function(x) {
d <- "r"
s <- with(x , {
r <- if (exists("a", inherits = FALSE)) {
a + b
} else {
0
}
dd <- if (exists("d", inherits = FALSE)) {
1
} else {
0
}
list(r, dd)
})
s
}
zz <- list(a = 1 , b = 3)
foo(zz)
goo <- \(x, ...) {
q <- 1
r <- "H"
tee()
}
tee <- \() {
parent.frame() |>
as.list()
}
goo(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment