[R] Iterating Named List
Gundala Viswanath
gundalav at gmail.com
Tue Aug 5 16:16:41 CEST 2008
Hi all,
I have the following named list:
> print(y)
$`200052_s_at`
[1] -1066.975 -1063.893 -1062.815 -1062.121 -1059.004
$`200071_at`
[1] -959.823 -953.980 -953.886 -948.781 -974.890
$`200084_at`
[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):
__BEGIN__
ny <- names(y)
for (i in ny) {
val <- paste("`",i,"`",sep="")
print(y$val)
# later we want to process y$val
}
__END__
However the after printing it gives "NULL".
What's wrong with my code above?
- Gundala Viswanath
Jakarta - Indonesia
More information about the R-help
mailing list