Message-ID: <3BBDA3DD-0D40-4A4D-A188-FC05BFBCD790@gmail.com>
Date: 2009-02-27T04:27:08Z
From: Alexy Khrabrov
Subject: accessing and preserving list names in lapply
In-Reply-To: <6A9CC2D5-C174-48D7-A280-6531333D28A1@gmail.com>
> res <- lapply(1:length(L),do.one)
Actually, I do
res <- lapply(:length(L),function(x)do.one(L[x]))
-- this is the price of needing the element's name, so I have to both
make do.one extract the name and the meat separately inside, and
lapply becomes ugly. Yet the obvious alternatives -- extracting the
names separately, attaching them back into list elements, etc., -- are
even uglier. Something pretty? :)
Cheers,
Alexy