[R] R for loop question

Douglas M. Hultstrand dmhultst at metstat.com
Tue May 20 18:58:16 CEST 2008


Hello,

I am trying to assign a variable name (x1,x2,x3...) in a loop statement 
that is based on a counter (counter is based on the number of hours 
within the datafile).  The x1,x2 data will later be called for plotting 
the data.  Below is a clip of the for loop I am using, any suggestions?

k = 1
for (i in 1:length(stats$hour)) {
  "x(i)" = dataset[k,(3:15)]
  k = k+1
 }

Thanks,
Doug

-- 
---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhultst at metstat.com
web: http://www.metstat.com



More information about the R-help mailing list