Extract names of objects from list

前端 未结 2 847
孤街浪徒
孤街浪徒 2020-11-30 01:32

I have a list of objects. How do I grab the name of just one object from the list? As in:

LIST <- list(A=1:5, B=1:10)
LIST$A
some.way.cool.function(LIST$         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 02:21

    You can just use:

    > names(LIST)
    [1] "A" "B"
    

    Obviously the names of the first element is just

    > names(LIST)[1]
    [1] "A"
    

提交回复
热议问题