> delayedAssign("foo$bar", 2)
>
> foo$bar # 1
>
> `foo$bar` # 2
Yes, you assign to the new variable `foo$bar`, not to bar component of the foo
variable!
You can use an environment for doing what you want:
e <- new.env()
e$bar <- 1
delayedAssign("bar", 2, assign.env = e)
e$bar
But notice also
I am fascinated by lazy evaluation mechanism provided by delayedAssign. Like
delayedAssign("foo", {
Sys.sleep(1) # or any other time consuming operations
1
}
Time consuming operations will be evaluated only if object "foo" is used.
But when I try:
foo <- list()
foo$bar <- 1
2 matches
Mail list logo