[R] lower triangle of the correlation matrix with xtable

Olga Lyashevska olga at herenstraat.nl
Thu Sep 2 16:14:02 CEST 2010


if I try as.dist I get the following error:

On Thu, 2010-09-02 at 09:57 -0400, Sarah Goslee wrote:
> > 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

print(xtable(as.dist(cor(mydata)),digits=3)) 
Error in UseMethod("xtable") : 
  no applicable method for 'xtable' applied to an object of class "dist"

Jorge's solution with upper.tri works fine!

Thanks everyone for your prompt response.

Cheers
Olga



More information about the R-help mailing list