Dear all,

I am trying to calculate the mean of one column for many data frames. The code 
I am using is as follows:

> for (i in seq(nrow(index))) {
        assign(paste(model, "_mean_",index$year[i], index$month[i], sep=''),
              mean(get(paste(model, index$year[i], index$month[i], "[,3]", 
sep=''))))
         }

Error in get(paste(model, index$year[i], index$month[i], "[,3]", sep = "")) : 
  object 'cccma207101[,3]' not found

The error message I'm getting is strange, because this object does exist:

str(cccma207101[,3])
 num [1:61538] 0.687 2.661 0 0 0 ...

If I leave the "[,3]" out of the loop, the code seems to work fine - so I'm 
isolating this as the cause of the problem for now.

My question is therefore, how can I use the above code to extract column three 
from each of the (360) data frames?

Many thanks for any help offered,

Steve

                                          
_________________________________________________________________
Got a cool Hotmail story? Tell us now

______________________________________________
R-help@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.

Reply via email to