Suppose I get some function from a client
f <- function(x) {
if (x) {
y <- 0
} else {
y <- 1
}
}
Since I get it from a client I cannot modify anything within f (aka substitute <- with <<-, or explicitly attach variables to the global environment).
Is there a way to somehow access all of the variables created within f with whatever values got assigned to them (after I ran it) from the global environment ? For example: if I ran
f(TRUE)
I would be able to access a variable "y" in the global environment and see that it is set to "0". I am not worried about overwriting anything in the global environment.
Thanks!