Re: [R] matrix multiplication question

2008-07-18 Thread Tsjerk Wassenaar
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 [EMAIL PROTECTED] 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   11  1 1  1  1  1   1   1   1   1
 1   1   1   1   1
 Shadow 0 1 1  1   1 1  1  1  0   11  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@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

__
R-help@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.


Re: [R] matrix multiplication question

2008-07-18 Thread Doran, Harold
Once you get your matrices in order you do not want to use t(X) %*% X. Instead, 
use crossprod(X). They do the same thing, but the former is the matrix 
operations based on the algebraic representation whereas numerical analysts 
will prefer the methods used in crossprod (hence the reason it exists).


-Original Message-
From: [EMAIL PROTECTED] on behalf of Duncan Murdoch
Sent: Fri 7/18/2008 1:00 AM
To: Murali K
Cc: r-help@r-project.org
Subject: Re: [R] matrix multiplication question
 
On 17/07/2008 9:47 PM, Murali K 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:

It's hard to say for sure, but it looks as though X1 really isn't a 
numeric matrix.  The ones and Shadow entries on the left look like 
character or factor data.

To find out what X1 is, you can run str(X1).

Duncan Murdoch
 
 
 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   11  1 1  1  1  1   1   1   1   1
 1   1   1   1   1
 Shadow 0 1 1  1   1 1  1  1  0   11  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@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.

__
R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.


[R] matrix multiplication question

2008-07-17 Thread Murali K
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   11  1 1  1  1  1   1   1   1   1
1   1   1   1   1
Shadow 0 1 1  1   1 1  1  1  0   11  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@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.


Re: [R] matrix multiplication question

2008-07-17 Thread Duncan Murdoch

On 17/07/2008 9:47 PM, Murali K 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:


It's hard to say for sure, but it looks as though X1 really isn't a 
numeric matrix.  The ones and Shadow entries on the left look like 
character or factor data.


To find out what X1 is, you can run str(X1).

Duncan Murdoch



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   11  1 1  1  1  1   1   1   1   1
1   1   1   1   1
Shadow 0 1 1  1   1 1  1  1  0   11  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@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.


__
R-help@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.