Access lapply index names inside FUN

Is there a way to get the list index name in my lapply() function?

n = names(mylist)
lapply(mylist, function(list.elem) { cat("What is the name of this list element?\n" })

I asked before if it’s possible to preserve the index names in the lapply() returned list, but I still don’t know if there is an easy way to fetch each element name inside the custom function. I would like to avoid to call lapply on the names themselves, I’d rather get the name in the function parameters.

12 Answers
12

Leave a Comment