[R] blank upper or lower triangle of cor-matrix

Christos Hatzis christos at nuverabio.com
Wed Feb 7 20:16:10 CET 2007


You can try

as.dist(d)


Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.com
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Leo Gürtler
> Sent: Wednesday, February 07, 2007 1:36 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] blank upper or lower triangle of cor-matrix
> 
> Dear altogether,
> 
> I want to blank the lower (or upper) part of a correlation 
> matrix as it is done by dist()
> 
> example:
> 
> ( d <- cor(matrix(runif(12),nrow=4)) )
> 
> If I do the following
> 
> d[lower.tri(d)] <- ""
> 
> of course everything is changed to character - that's not 
> what should be.
> Additionally, it does not work to assign "0" or anything 
> else. The same is true for assigning "NA".
> 
> However, what I want is like the following:
> 
> ( dist(matrix(runif(12),nrow=4)) )
> 
> Looking into dist(), it seems that the calculation and the 
> matrix are done in C and not in plain R.
> 
> How can I realize it?
> 
> thanks!
> 
> best,
> 
> leo
> 
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
> 
>



More information about the R-help mailing list