[R] Iterating Named List

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Tue, 05 Aug 2008 23:16:41 +0900

Hi all,

I have the following named list:

> print(y)

[1] -1066.975 -1063.893 -1062.815 -1062.121 -1059.004

[1] -959.823 -953.980 -953.886 -948.781 -974.890

[1] -1135.804 -1132.863 -1128.197 -1128.633 -1125.890

What I want to do is to iterate this name list and process its members. To do that I attempt the following code (but failed):

ny <- names(y)

for (i in ny) {

   val <- paste("`",i,"`",sep="")

   # later we want to process y$val

However the after printing it gives "NULL". What's wrong with my code above?

R-help_at_r-project.org 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. Received on Tue 05 Aug 2008 - 14:20:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Aug 2008 - 11:33:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive