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 e
Also building on @joran's answer, you can write a wrapper function that preserves object attributes such as below:
lapply_preserve_names <- function(list, fun){
lapply(seq_along(list), function(i) {
obj = list[i]
names(obj) = names(list)[i]
fun(obj)
})
}
then instead of using lapply, simply use lapply_preserve_names(your_list, function)