Skip to content
Prev 171911 / 398506 Next

accessing and preserving list names in lapply

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