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*(j-1)+1):10*j])
Regards,
Moshe.
--- Luca Penasa <luca.penasa at email.it> wrote:
> 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 the exemple the original matrix would be divided
> into 50
> partial-matrix, for every partial-matrix should be
> extracted a value
> obtained from a weightened mean: the cell at center
> of the
> partial-matrix should have the max importance into
> the mean, the fhurter
> cell should have the lower importance (something
> like a gaussian shape,
> where i can decide the sigma used).... In this way
> i'll obtain a
> resampled matrix with the values calculated using a
> weightened mean of
> the single partial-matrix...
>
> Is there anybody who can suggest me a way to do
> this??? is there a
> function that can do this?
>
> PS: sorry for my english... and... im a newbie,
> please try to explain in
> a simple way.. thank you
>
> Luca Penasa,
> geology student,
> University of Padua, Italy
>
>
>
>
> --
> Email.it, the professional e-mail, gratis per te:
> http://www.email.it/f
>
> Sponsor:
> In REGALO 'All the Good Thing' di NELLY FURTADO
> Clicca qui:
>
http://adv.email.it/cgi-bin/foclick.cgi?mid=6617&d=12-11>
> ______________________________________________
> R-help at 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.
>