[Rd] iterated lapply

Jeroen Ooms jeroenooms at gmail.com
Mon Feb 23 22:45:32 CET 2015


On Mon, Feb 23, 2015 at 12:57 PM, Daniel Kaschek
<daniel.kaschek at physik.uni-freiburg.de> wrote:
> Is this a bug or a feature?

I think it is a bug. If we use substitute to inspect the promise, it
appears the index number is always equal to its last value:

vec <- c("foo", "bar", "baz")
test <- lapply(vec, function(x){
  function(){x}
})
substitute(x, environment(test[[1]]))
substitute(x, environment(test[[2]]))



More information about the R-devel mailing list