[R] symmetric matrix

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Tue Nov 29 13:02:10 CET 2005


Use as.matrix() :

 m <- round( as.dist( cor( matrix( rnorm(600), nc=6 ) ) ), 2 )
 m
      1     2     3     4     5
2 -0.05
3  0.01  0.03
4  0.00  0.05  0.00
5  0.20  0.07  0.09 -0.07
6  0.03  0.02  0.11 -0.15 -0.11

 as.matrix( m )
      1     2    3     4     5     6
1  0.00 -0.05 0.01  0.00  0.20  0.03
2 -0.05  0.00 0.03  0.05  0.07  0.02
3  0.01  0.03 0.00  0.00  0.09  0.11
4  0.00  0.05 0.00  0.00 -0.07 -0.15
5  0.20  0.07 0.09 -0.07  0.00 -0.11
6  0.03  0.02 0.11 -0.15 -0.11  0.00




On Tue, 2005-11-29 at 03:04 -0800, Robert wrote:
> I have the following matrix:
>             1         2        3        4         5
> 2 0.7760856                                      
> 3 2.0222216 1.6907899                            
> 4 0.6148687 0.2424415 1.593916                   
> 5 3.0227028 2.3636083 1.512634 2.426591          
> 6 3.2104434 2.5334957 1.730422 2.608584 0.2184739
>   the diagonal is 0 and it is a symmetric matrix.
>   Is there any function to return to the normal one?
>   That is, the 6 by 6 one?
>    
> 
> 		
> ---------------------------------
> 
>  Single? There's someone we'd like you to meet.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list