[R] Error during matrix multiplication

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Thu Sep 13 08:57:03 CEST 2012


You used neither str() nor dput(), you still haven't provided reproducible code (your code reads csv, but you did not supply csv), and you are posting in html as the posting guide requests that you not do (but you probably didn't read that either). A more verbose description of how to ask a question can be found at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example .
 Hmmm... maybe that is your clue though... if your files actually look like you are showing them, then they are NOT csv files, and you should not be using sep="," or you should re-create them as csv files. But don't guess... read up at the link above and learn how to see what is really going on.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

"s.s.m. fauzi" <ssmfone at gmail.com> wrote:

>Yes,
>I have a row and column header. I need to save the row and column
>header.
>Here is the example of the data
>
>*Whirr_127.csv*
>WHIRR.127 WHIRR.128 WHIRR.129 WHIRR.137 WHIRR.139 WHIRR.140 WHIRR.141
>WHIRR.145 WHIRR.146 WHIRR.147
>Adrian Cole         0         0         1         0         0         0
>    0         0         0         0
>Alison Wong         0         0         0         0         0         0
>    1         0         0         0
>Jakob Homan         0         0         0         0         1         0
>    0         0         0         0
>Tibor Kiss          0         1         0         0         0         0
>    0         0         1         0
>Tom White           1         0         0         1         0         0
>    0         1         0         1
>Unassigned          0         0         0         0         0         1
>    0         0         0         0
>
>*Files_Whirr_127.csv*
>*
>pom.xml. ZooKeeperServiceTest.java HBaseServiceController.java
>HadoopServiceController.java. BasicServerClusterActionHandler.java.
>AbstractClusterSpecCommand.java.
>WHIRR-127        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-128        1                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-129        1                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-137        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-139        1                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-140        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-141        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-145        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-146        0                         0                          
>0
>                          0                                     0
>                     0
>WHIRR-147        0                         0                          
>0
>                          0                                     0
>                     0
>
>(cut to save space)
>
>*
>
>On Thu, Sep 13, 2012 at 3:37 PM, Jeff Newmiller
><jdnewmil at dcn.davis.ca.us>wrote:
>
>> You need to learn to use the str() function to debug these kinds of
>> problems. And you need to learn to provide data with your code
>(perhaps
>> with the dput function) so others can reproduce your problem if you
>want
>> help.
>>
>> I would guess that you have non-numeric data in your files.
>>
>---------------------------------------------------------------------------
>> Jeff Newmiller                        The     .....       .....  Go
>Live...
>> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
>> Go...
>>                                       Live:   OO#.. Dead: OO#.. 
>Playing
>> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
>> /Software/Embedded Controllers)               .OO#.       .OO#. 
>rocks...1k
>>
>---------------------------------------------------------------------------
>> Sent from my phone. Please excuse my brevity.
>>
>> "s.s.m. fauzi" <ssmfone at gmail.com> wrote:
>>
>> >Hi,
>> >I have two matrix from two different .csv files.
>> >
>> >#load .csv files
>> >a <- as.matrix(read.table("Whirr_127.csv", header=T, sep=",",
>> >row.names=1))
>> >b <- as.matrix(read.table("Files_Whirr_127.csv", header=T, sep=",",
>> >row.names=1))
>> >a
>> >b
>> >
>> >I managed to do transpose to 'b' without any error.
>> >
>> >transpose_task <- t(b)
>> >transpose_task
>> >
>> >But, when I tried to do multiplication (a%*%transpose_task), an
>error
>> >occured.
>> >
>> >td <- (a%*%transpose_task)
>> >td
>> >
>> >Here is the error:
>> >ERROR:  requires numeric/complex matrix/vector arguments
>> >ERROR:  object 'td' not found
>> >
>> >Anybody can help me to solve this?
>> >
>> >Thank you
>> >
>> >       [[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.
>>
>>




More information about the R-help mailing list