[R] matrix multiplication question

Tsjerk Wassenaar tsjerkw at gmail.com
Fri Jul 18 08:25:42 CEST 2008


Hi Murali,

So, the solution to your problem will be to explicitly convert your
matrix to a numeric matrix. Maybe matrix (?matrix) will do, or you'll
also have to use as.numeric (?as.numeric).
The strings on the left seem to me to be the row labels, right..?, not
elements in the matrix/table.

As a newbie, the thing you probably have to get used to/read up with
is the distinction between tables, which can contain any sort of data
and can not always be used in matrix calculations and (numeric)
matrices/vectors.

Cheers,

Tsjerk

On Fri, Jul 18, 2008 at 3:47 AM, Murali K <murali.jnu1 at gmail.com> wrote:
> Hello,
>        I am a newcomer to R and therefore apologize for posting such a
> basic question. I am
> trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is:
>
>
>            1 2  3  4  5 8 12 13 20 24  26 27  31 33 34 36 37 40 41 42 45 46
> 47 48 49
> ones     1  1 1  1  1 1  1  1  1   1    1  1     1  1  1  1   1   1   1   1
> 1   1   1   1   1
> Shadow 0 1 1  1   1 1  1  1  0   1    1  1     1  0  1  0   1   0   1   1
> 0   1   0   1   0
>
> However, when I try to perform this operation, I obtain:
> Error in t(X1) %*% X1 : requires numeric matrix/vector arguments
>
> Can someone please tell me what I seem to be doing wrong? thanks.
>
> Sincerely,
> Murali Kuchibhotla
>
>
> Murali Kuchibhotla
> Department of Economics
> Iowa State University
> Office:75,Heady
> Phone:515-294-5452
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Tsjerk A. Wassenaar, Ph.D.
Junior UD (post-doc)
Biomolecular NMR, Bijvoet Center
Utrecht University
Padualaan 8
3584 CH Utrecht
The Netherlands
P: +31-30-2539931
F: +31-30-2537623



More information about the R-help mailing list