1
votes

I am extremely new to R and I'm trying to learn as much as I can from several sources. I am currently working on a problem that I have for class, which more than likely has a simple solution. However, when I go to multiply the matrices I have, I get a non-conformable arrays. Here are my matrices.

y1 <- c(2,4,7)  
y1 <- matrix(data= y1, nrow = 1, ncol=3)

y2 <- c(5,3,8)
y2 <- matrix(data= y2, nrow = 3, ncol=1)`

y1%%y2 Error in y1%%y2 : non-conformable arrays

Can someone please tell me what I'm doing wrong? Any help is appreciated

1
Do you need y1 %*% c(y2)akrun
@akrun That got rid of the non-conformity arrays, but why did you add a 'c' to the multiplication? What does that mean exactly?Aleox
It removes the dimenssions of the matrix and coerces to a vectorakrun
@akrun Does this mean that this should be used when multiplying all matrices that have non-conformity array errors without the 'c' , or just in this case? Just to clear one last thing up.Aleox
Sorry, your expression was not correct y1 %*% y2 ( I didn't notice it earlier)akrun

1 Answers

0
votes

The issue was because %% is a different function whereas we need %*%

y1 %*% y2