Re: [R] Resample a matrix (table)

2007-11-12 Thread Moshe Olshansky
Hi Luca, One (not very elegant) way of doing this is to use double loop as below: Let A be your matrix (100x50), W your weights matrix (10x10) and you want to produce matrix B (10X5) You can do: B <- matrix(0,nrow=10,ncol=5) for (i in 1:10) for (j in 1:5) B[i,j] <- sum(W*A[(10*(i-1)+1):10*i,(10*(

[R] Resample a matrix (table)

2007-11-12 Thread Luca Penasa
I have a matrix of values... for exemple the matrix could be 100 rows and 50 columns... I would like to resample the matrix to obtain a new matrix -> a 10x5 matrix So i need to calculate a new value for every cell, i would like to use a weightened mean to do this. I explain this thing better: In th