[R] How to get the names of list elements when iterating over a list?

Peng Yu pengyu.ut at gmail.com
Wed Nov 11 17:02:08 CET 2009


I need to get the names of the list elements when I iterate over a
list. I'm wondering how to do so?

alist=list(a=c(1,3),b=c(-1,3),c=c(-2,1))
sapply(alist,function(x){
      #need to use the name of x for some subsequent process
    })




More information about the R-help mailing list