Displaying 2 results from an estimated 2 matches for "gete2".
Did you mean:
get32
2015 Jan 27
0
Inspect a "delayed" assigned whose value throws an error?
...function(n) eval(substitute(substitute(X, e), list(X=n))))
> gete(e)
[[1]]
1 + 2
[[2]]
[1] "y"
[[3]]
{
cat(" HO! ")
pi + 2
}
>
In newer versions of R, you can use 'ls(e)' instead of
'ls(env=e)', and we have bquote() to make it a tad shorter:
gete2 <- function(e)
lapply(lapply(ls(e), as.name), function(n) eval(bquote(substitute(.(n), e))))
Apart from that (and from not using spaces and from silly things
such as 'L = lapply', and using L),
can anyone find a shorter (or "nicer") way to achieve the same
as gete(), or ge...
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
On Mon, Jan 26, 2015 at 12:24 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> If it was any other environment than the global, you could use substitute:
>
> e <- new.env()
> delayedAssign("foo", stop("Hey!"), assign.env = e)
> substitute(foo, e)
>
> delayedAssign("foo", stop("Hey!"))
> substitute(foo)
Hmm... interesting