[R] transform matrix

Sean Davis sdavis2 at mail.nih.gov
Tue Nov 29 12:52:16 CET 2005


On 11/29/05 6:46 AM, "Robert" <samrobertsmith at yahoo.com> wrote:

> I run the following code and got a wrong message. Anyway to transform test1 to
> a 6 by 6 matrix? many thanks!
>> test1
>         1         2        3         4         5         6
> 1 0.0000000 0.7760856 2.022222 0.6148687 3.0227028 3.2104434
> 2 0.7760856 0.0000000 1.690790 0.2424415 2.3636083 2.5334957
> 3 2.0222216 1.6907899 0.000000 1.5939158 1.5126344 1.7304217
> 4 0.6148687 0.2424415 1.593916 0.0000000 2.4265906 2.6085845
> 5 3.0227028 2.3636083 1.512634 2.4265906 0.0000000 0.2184739
> 6 3.2104434 2.5334957 1.730422 2.6085845 0.2184739 0.0000000
>> tryD=matrix(data = test1, nrow = 6, ncol = 6)
> Warning message: 
> Replacement length not a multiple of the elements to replace in matrix(...)

What is test1?  Try:

tryD <- as.matrix(test1)

Does that do it?  

Sean




More information about the R-help mailing list