[R] product of successive rows

Moshe Olshansky m_olshansky at yahoo.com
Tue Jul 29 09:51:08 CEST 2008


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 <mpdotbook at gmail.com> wrote:

> From: rcoder <mpdotbook at gmail.com>
> Subject: [R]  product of successive rows
> To: r-help at 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 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.



More information about the R-help mailing list