Kevin,
Thanks for the explanation. Based on your analysis, I tried to reproduce
the problem without lapply, and sure enough:
(function(x,y) "$"(x,y)) (list(a=2),"a") => NULL
(function(x,...) "$"(x,...)) (list(a=2),"a") => NULL
although
"$"(list(a=2),"a") => 2
Looking for even simpler example
`lapply` basically takes its call and massages into calls of the following form:
FUN(X[[1L]], ...)
FUN(X[[2L]], ...)
...
that get evaluated in the appropriate environment.
For `lapply(list(list(a=3,b=4)),"$","b")`, you can imagine that a
function `FUN` of the form:
FUN <- funct
There seems to be a funny interaction between lapply and "$" -- also, "$"
doesn't signal an error in some cases where "[[" does.
The $ operator accepts a string second argument in functional form:
> `$`(list(a=3,b=4),"b")
[1] 4
lapply(list(list(a=3,b=4)),function(x) `$`(x,"b"))
[[1]]
[1] 4
...