[R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

Casper Ti. Vector caspervector at gmail.com
Thu May 3 12:31:18 CEST 2012


As the title says, I want to apply a function (which itself returns
a function) to a list (or vector), and get a list (or vector) of
generated functions as the return value, but get unexpected result.

Anyone with an idea about the reason of this phenomenon and a correct
way to implement the requirements? Thanks very much :)

-- 
Using GPG/PGP? Please get my current public key (ID: 0xAEF6A134, valid
from 2010 to 2013) from a key server.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120503/bc0b3e2a/attachment.bin>


More information about the R-help mailing list