Skip to content
Prev 205092 / 398506 Next

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

On Jan 1, 2010, at 8:21 AM, Mark Heckmann wrote:

            
It did "work" in the sense that it created a list of the same  
structure with each node now named "new name". If you want that named  
list to become "l", then you need to do an assignment:

l <- lapply(l, function(x) {names(x) <- "new name";  return(x) })
 > l
$a
new name
       NA

$b
new name
       NA