Hi all,
I would like to iterate through a list with named elements and access the
names within an lapply / sapply call. One way to do this is iterate through
the names and index the list with the name. Is there a way to iterate
through the list elements themselves and access the element names within in
the function? For example,
mylist <- list("a"=c(1,2),"b"=c(3,4),"c"=c(5,6))
sapply(mylist,function(x){
#get name of list elements ("a", "b", "c")
#then do other stuff
})
Thanks for your suggestions.
Jonathan
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.