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 ... but using an lapply "..." argument, this returns NULL: > lapply(list(list(a=3,b=4)),"$","b") [[1]] NULL Equally strangely, a symbol is an error in functional form: > `$`(list(a=3,b=4),quote(`b`)) Error in list(a = 3, b = 4)$quote(b) : invalid subscript type 'language' ... but not an error in lapply, where it returns NULL: > lapply(list(list(a=3,b=4)),`$`,quote(`b`)) [[1]] NULL I wonder if lapply is failing to pass the second argument to $ correctly, since $ with various unreasonable second arguments returns NULL (shouldn't it given an error?): "$"(list(list(a=3,b=4)),) => NULL lapply(list(list(a=3,b=4)),`$`,function(i)i) => NULL Compare "[["(list(list(a=3,b=4)),) => <<error>> But with [[, lapply correctly gives an error: lapply(list(list(a=3,b=4)),`[[`,function(i)i) => <<error>> [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel