Closed richierocks closed 7 years ago
It's because the R6 object is an environment whose parent environment is the empty env. When you run with(test, {data})
, it evaluates the expression {data}
in the test
environment. R searches test
for {
, doesn't find it, and then searches the ancestor environments of test
; because the only ancestor the empty env, which contains nothing, it throws that error.
You'd get a similar error if you were to do this:
with(test, 1+1)
# Error in eval(expr, envir, enclos) : could not find function "+"
Or this:
e <- new.env(parent = emptyenv())
with(e, 1+1)
# Error in eval(expr, envir, enclos) : could not find function "+"
You may be able to write a with.R6
method that handles this case, but it's highly unlikely that it would be merged in this repo, because I generally avoid using with
.
To reproduce:
I know I can work around this by doing
test$data
, but not being able to find{
seems interestingly weird and I wonder what is going on.