Access lapply index names inside FUN

前端 未结 12 2167
自闭症患者
自闭症患者 2020-11-22 15:04

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         


        
12条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 15:35

    I've had the same problem a lot of times... I've started using another way... Instead of using lapply, I've started using mapply

    n = names(mylist)
    mapply(function(list.elem, names) { }, list.elem = mylist, names = n)
    

提交回复
热议问题