Re: [R] delayedAssign list members

2014-03-04 Thread Philippe Grosjean
> 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

[R] delayedAssign list members

2014-03-04 Thread Shan Huang
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