Re: [R] Compute RowMeans from mulple files

2015-08-24 Thread Bert Gunter
Note that, in general, rowMeans(x) is preferable to apply(x,1,mean) Consult ?rowMeans for details. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Mon, Aug 24, 2015 at 2:20 AM, Jim Lemon wro

Re: [R] Compute RowMeans from mulple files

2015-08-24 Thread Jim Lemon
Hi Peter, I think your problem is that your calculations occur after the end of the loop. What you probably want is something like this: yr_means<-mam_means<-jf_means<- jja_means<-ond_means<-rep(NA,length(prec_files)) for (i in 1:length(prec_files)) { prec_data<-read.delim(prec_files[i], sep="\t

Re: [R] Compute RowMeans from mulple files

2015-08-23 Thread Peter Tuju
Dear R users, I have fifty two (52) text files with the same dimensions (ie 31 by 13). Three sample of such data files are attached. I want to compute the rowMeans for each separate file for;(i) all the months (ii) For January and February (iii) For March, April and May (iv) For June, July and