Re: [R] Problem on Matrix multiplication

From: Michal Bojanowski <>
Date: Thu 15 Jun 2006 - 20:34:15 EST


AKS> But when I want to get [transpose(weight)][s][weight] using following AKS> syntax,

AKS> t(weight)%*%s%*%weight

I guess 'weight' and 's' are dataframes and you need matrices. Like here:

x <- rnorm(8)
s <- matrix(rnorm(64), ncol=8)

t(x) %*% s %*% x # this is OK

d <-
t(d) %*% s %*% d # this is your error

You can use data.matrix() to convert dataframes to matrices:

t( data.matrix(d) ) %*% s %*% data.matrix(d) # again OK

HTH, Michal


Michal Bojanowski
Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
Room 1428 mailing list PLEASE do read the posting guide! Received on Thu Jun 15 20:37:49 2006

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 Thu 15 Jun 2006 - 22:10:48 EST.

Mailing list information is available at Please read the posting guide before posting to the list.