[R] decompose a correlation matrix

Liaw, Andy andy_liaw at merck.com
Thu Sep 23 21:04:44 CEST 2004


> From: Mark Strivens
> 
> Thanks for the answers the appear to be just
> right. 
> 
> i.e. 
> 
> corrmat[upper.tri(corrmat)]
> 
> or
> 
> x[col(x)>row(x)] 
> 
> The slight problem is I lose all the column &
> row labels from the correlation matrix, so I 
> am not sure of the order of the values (i.e.
> which combination of markers the value 
> represents).
> 
> Is there anyway to drag the labels along with
> the value extraction?
> _________________________
> Department of Molecular and Human Genetics,
> Baylor College of Medicine,

idx <- upper.tri(x)
cbind(row=row(x)[idx], col=col(x)[idx], value=x[idx])

Best,
Andy




More information about the R-help mailing list