[R] Need help in matrix multiplication error

From: Jason Lee <huajie.lee_at_gmail.com>
Date: Tue, 20 May 2008 09:43:09 +1000


Hi,

I have a data file which is named test.txt as below. Prior to that, I have converted the last row from nominal to numeric using as.integer.

 Statement T1001 T1002 T1003 T1004 T1005 T100 T1014 T1021 T1022 T1023

1         0     0     0     0     0     0    0     0     1     0     0
2        0     0     0     0     0     0    0     0     1     0     0
3         0     1     0     0     1     0    0     0     1     0     0
4       406  pass  pass  fail  pass  pass pass  pass  pass  pass  pass

After as.integer of "pass", the below data is been transformed.

 Statement T1001 T1002 T1003 T1004 T1005 T100 T1014 T1021 T1022 T1023

1         0     0     0     0     0     0    0     0     1     0     0
2        0     0     0     0     0     0    0     0     1     0     0
3         0     1     0     0     1     0    0     0     1     0     0
4       0      1      1     0     1    1     1     1     1     1     1


The 1,2,3 and 4 on the first column is the automatic numbering seen on the terminal when i pasted here.

And, i try to use matrix multiplication which is as.matrix(data[1:3,2:11])%*% sign(t(data[4,2:11])) Basically i wanted to count from column 2 onwards..which i want to ignore the Statement column data.

Error in sign(t(data[4, 2:11])) : Non-numeric argument to mathematical function.
I try take off the column constraint which is as.matrix(data[1:3,])%*% sign(t(data[4,])) but it still gives me
Error in sign(t(data[4, ])) : Non-numeric argument to mathematical function

I didnt understand how this error relate to my data above. Because my data is not a character at the first place and its a data.frame.

Please help.Thanks..

Rgrds,
Jason

        [[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. Received on Mon 19 May 2008 - 23:53:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 06:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive