Re: [R] Matrix operations in a list

From: Christos Hatzis <christos_at_nuverabio.com>
Date: Tue 23 Jan 2007 - 15:46:35 GMT

Try,

mapply('%*%', a, b, SIMPLIFY=FALSE)

-Christos

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Doran, Harold Sent: Tuesday, January 23, 2007 10:22 AM To: r-help@stat.math.ethz.ch
Subject: [R] Matrix operations in a list

I have matrices stored within a list like something as follows:

a <- list(matrix(rnorm(50), ncol=5), matrix(rnorm(50), ncol=5)) b <- list(matrix(rnorm(50), nrow=5), matrix(rnorm(50), nrow=5))

I don't recall how to perform matrix multiplication on each list element such that the result is a new list

result <- list(a[[1]]%*%b[[1]], a[[2]]%*%b[[2]])

I think I'm close with mapply(), but I'm doing something silly

mapply('%*%', a,b)

Thanks.
Harold

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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. Received on Wed Jan 24 03:10:12 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 23 Jan 2007 - 17:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.