[R] matrix multiplication

Rolf Turner
Wed, 12 Oct 2011 04:16:33 -0000

On 12/10/11 09:11, flokke wrote:
> Dear all,
> Sorry to bother you with such a stupid question, but I just cannot find the
> solution to my problem.
>
> I'd like to use matrix multiplication for meanA and factorial 3.
> I use the command meanA%*%factorial 3.
> But everything I get is: Error in factorial3 %*% A : non-conformable
> arguments
>
> I know that the number of the columns of the first vector
     first ***MATRIX***
> has to be the same
> number of rows of the
> second vector
     second ***MATRIX***
> to be able to use matrix multiplication, but that is the case
> here.
     No it isn't!!!  Your ``factorial3'' has ***one*** row, and
     ``meanA'' has ***two*** columns.  So the arrays are
     not conformable, just like the error message says!

     There are three sorts of people; those who can count,
     and those who can't!
> I also tried it with
> two columns for factorial 3 and that didnt work either.

     Try it with two ***rows*** for factorial3!!!

     And watch those spaces in names.  They don't
belong.
> Can someone help me out with this?'
>
> these are my matrices:
>
> meanA
>           [,1]     [,2]
> [1,] 3.666667 4.666667
>
>> factorial3
>       [,1]
> [1,]    1

To repeat:  (1 x 2) times (1 x 1) doesn't work.
Note that (n x 2) times (2 x m) *does* work, and gives an (n x m) result.

     cheers,

         Rolf Turner