[R] lower triangle of the correlation matrix with xtable

Sarah Goslee sarah.goslee at gmail.com
Thu Sep 2 15:57:10 CEST 2010


Like this?

> mydata<-data.frame(x1=c(1,4,6),x2=c(3,1,2),x3=c(2,1,3))
> as.dist(cor(mydata))
           x1         x2
x2 -0.5960396
x3  0.3973597  0.5000000

Sarah

On Thu, Sep 2, 2010 at 9:51 AM, Olga Lyashevska <olga at herenstraat.nl> wrote:
> Dear all,
>
> mydata<-data.frame(x1=c(1,4,6),x2=c(3,1,2),x3=c(2,1,3))
> cor(mydata)
>           x1         x2        x3
> x1  1.0000000 -0.5960396 0.3973597
> x2 -0.5960396  1.0000000 0.5000000
> x3  0.3973597  0.5000000 1.0000000
>
> I wonder if it is possible to fill only lower triangle of this
> correlation matrix? Using 'dist' doesn't seem to be useful as it doesnt
> allow to convert this table with xtable.
>
> print(xtable(cor(mydata),digits=3))
>
> Any ideas?
> Cheers,
> Olga
>



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list