[R] changing a list element's name during execution in lapply - possible?

Mark Heckmann mark.heckmann at gmx.de
Fri Jan 1 14:21:47 CET 2010


Happy New Year, all!

I want to do calculations on each element of a list l, but i want the  
returned list element to be named differently after the calculation.
Is it possible to do the renaming somehow within the lapply call?

	l <- list(a=NA, b=NA)
	lapply(l, function(x) {names(x) <- "new name";  return(x) })

This does not work, any ideas?
TIA

–––––––––––––––––––––––––––––––––––––––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com



More information about the R-help mailing list