The best approach is to put all those datasets into a list, then you can loop
through the elements of the list, or use lapply or sapply on the list.
If you insist on keeping them outside of a list, or need a loop to put them into
the list, then look at the 'get' function.
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of MatAra
Sent: Friday, September 09, 2011 12:26 PM
To: r-help at r-project.org
Subject: [R] Looping through multiple datasets already in memory
Gents,
I have the following loop:
for (i in (seq(along=Draw.1[,1]))) {print(i)} # from 1 - 5 (counter)
for (i in (seq(along=Draw.1[,1]))) {print(Draw[i,4])} # from the 1 - column
(passes parameter per column)
Now: I have multiple Draws [Draw.1 - Draw.100] in memory with different
"orders"
Question: How do I loop through each Draw.[j]? OR in other way, how do I
pick up all the datasets from memory dynamically?
Something like:
for (i in (seq(along=Draw.[J][,1]))) {print(Draw[i,4])}
paste() would not allow me to pick the [row,col] combination I need. It just
passes the list of all the elements.
paste(as.matrix(Draw), 1, sep=".")[10,5] DOES NOT WORK
Thanks in advanced for the ideas!
An example of how the draw (control files) looks like:
Draw.1
ID Name Tab Folder L/S
[1,] " 38" "Stoxx50_24_08_11" "38"
"Stoxx" "-1"
[2,] " 47" "Stoxx50_24_08_11" "47"
"Stoxx" " 1"
[3,] " 153" "DAX_31_08_11" "29"
"DAX" " 1"
[4,] " 256" "FT100_31_08_11" "12"
"UK" " 1"
[5,] " 303" "FT100_31_08_11" "59"
"UK" " 1"
--
View this message in context:
http://r.789695.n4.nabble.com/Looping-through-multiple-datasets-already-in-memory-tp3802453p3802453.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
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.