accessing and preserving list names in lapply
Hi, This might be the trick you are looking for: http://tolstoy.newcastle.edu.au/R/e4/help/08/04/8720.html Romain
Alexy Khrabrov wrote:
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
Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr