Dear all,
I would like to multiply two matrixes with the different dimension column
by column. Let make an example:
If I have two matrixes X and Yas follow:
X- matrix(1:12, nrow=4, ncol=3, dimnames=list(c(A,B,C,D),
c(stage1,stage2,stage3)))
Y- matrix(1:28, nrow=4, ncol=7,
Here are two ways:
1. Using inner from:
http://tolstoy.newcastle.edu.au/R/help/05/04/3709.html
try:
array(inner(t(X), Y, *), c(4, 21))
2. using model.matrix get all terms and interactions and eliminate the
non-interactions:
model.matrix(~ X * Y - X - Y - 1)
On
Majid Iravani wrote:
I would like to multiply two matrixes with the different dimension
column by column. Let make an example: If I have two matrixes X
and Yas follow:
X- matrix(1:12, nrow=4, ncol=3, dimnames=list(c(A,B,C,D),
c(stage1,stage2,stage3)))
Y- matrix(1:28, nrow=4, ncol=7,
apply(Y, 2, function(y)list(y*X))
On 13 Oct 2006, at 12:33, Majid Iravani wrote:
Dear all,
I would like to multiply two matrixes with the different dimension
column
by column. Let make an example:
If I have two matrixes X and Yas follow:
X- matrix(1:12, nrow=4, ncol=3,