Access and preserve list names in lapply function
I need to access list names inside the lapply function. I've found some threads online where it's said I should iterate through the names of the list to be able to fetch each list element name in my function: > n = names(mylist) > mynewlist = lapply(n, function(nameindex, mylist) { return(mylist[[nameindex]]) }, mylist) > names(mynewlist) NULL > names(mynewlist) = n The problem is that mynewlist loses the original mylist indexes and I have to add that last names() assignment to restore them. Is there a way to give an explicit index name to each element returned by the lapply function? Or a