Assuming that the number of rows is even and that your matrix is A, 
element-wise product of pairs of rows can be calculated as

A[seq(1,nrow(A),by=2),]*A{seq(2,nrow(A),by=2),]


--- On Mon, 28/7/08, rcoder <[EMAIL PROTECTED]> wrote:

> From: rcoder <[EMAIL PROTECTED]>
> Subject: [R]  product of successive rows
> To: r-help@r-project.org
> Received: Monday, 28 July, 2008, 8:20 AM
> 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.

______________________________________________
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.

Reply via email to