Hi rcoder,

Assuming that the number of rows of your matrix x is even, try also:

x <- matrix(1:72,12)
apply(x,2, tapply, rep(1:(nrow(x)/2),each=2),prod)

# or using a function which argument "x" is your matrix

prod.mat=function(x) {
k=nrow(x)
g=rep(1:(k/2),each=2)
apply(x,2, tapply, g,prod)
}

prod.mat(x)


HTH,

Jorge




On Sun, Jul 27, 2008 at 6:20 PM, rcoder <mpdotbook@gmail.com> wrote:

>
> Hi everyone,
>
> I want to perform an operation on a matrx that outputs the product of
> successive pairs of rows. For example: calculating the product between rows
> 1 & 2; 3 & 4; 5 & 6...etc.
>
> Does anyone know of any readily available functions that can do this?
>
> Thanks,
>
> rcoder
>
>
> --
> View this message in context:
> http://www.nabble.com/product-of-successive-rows-tp18681259p18681259.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

