Re: [R] Averaging 'blocks' of data

2008-09-08 Thread Adam D. I. Kramer
Hi Steve, You probably want to check out ?by or ?aggregate, maybe using (rownames(df) %/% 60) : (colnames(df) %/% 60) as your index variable. --Adam On Sun, 7 Sep 2008, Steve Murray wrote: Dear all, I have a large dataset which I hope to reduce in size, to make it more useable. I h

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread Robert A LaBudde
I'm not sure I exactly understand your problem, but if you are looking for a recursive algorithm for calculating the average by addition of one record only at a time, consider: y[k] = y[k-1] + (x[k] - y[k-1])/k, where y(0) = 0, k = 1, 2, ... At each stage, y[k] = (x[1]+...+x[k])/k. At 0

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread jim holtman
Here is a way to do it by reading in 60 lines at a time and computing the means: # create some test data n <- 360 x <- matrix(runif(360*16800), nrow=16800) cat(x, file="/tempxx.txt") # now process the data 60 lines at a time, averaging each 60x60 block result <- matrix(0, nrow=6, ncol=280) nextL

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread Steve Murray
Gabor - thanks for your suggestion... I had checked the previous post, but I found (as a new user of R) this approach to be too complicated and I had problems gaining the correct output values. If there is a simpler way of doing this, then please feel free to let me know. Dylan - thanks, your

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread Steve Murray
Gabor - thanks for your suggestion... I had checked the previous post, but I found (as a new user of R) this approach to be too complicated and I had problems gaining the correct output values. If there is a simpler way of doing this, then please feel free to let me know. Dylan - thanks, your

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread Dylan Beaudette
On Sun, Sep 7, 2008 at 12:32 PM, Steve Murray <[EMAIL PROTECTED]> wrote: > > > Dear all, > > I have a large dataset which I hope to reduce in size, to make it more > useable. I hope to do this by taking an average of each 60 x 60 blockof > values and forming a new data frame out of the averaged v

Re: [R] Averaging 'blocks' of data

2008-09-07 Thread Gabor Grothendieck
This was answered last month: http://tolstoy.newcastle.edu.au/R/e4/help/08/08/19091.html On Sun, Sep 7, 2008 at 3:32 PM, Steve Murray <[EMAIL PROTECTED]> wrote: > > > Dear all, > > I have a large dataset which I hope to reduce in size, to make it more > useable. I hope to do this by taking an av

[R] Averaging 'blocks' of data

2008-09-07 Thread Steve Murray
Dear all, I have a large dataset which I hope to reduce in size, to make it more useable. I hope to do this by taking an average of each 60 x 60 blockof values and forming a new data frame out of the averaged values. How would I go about taking averages of 60 x 60 'blocks' in R, and cycling