[R] correlation matrix

"Dénes TÓTH" tdenes at cogpsyphy.hu
Mon Oct 10 22:34:25 CEST 2011


And you might also consider packages like corrplot, corrgram etc. for
other plotting options of a correlation matrix.
They can be more informative than simply invoking image(heat)



> What a pleasant post to respond to - with self-contained code. :)
>
> heat<-matrix(0,nrow=dim(xa)[1],ncol=dim(xa)[2])
>
> heat[lower.tri(heat)]<-xa[lower.tri(xa)]
> heat[upper.tri(heat)]<-xb[upper.tri(xb)]
> diag(heat)<-1
>
> heat
>
> HTH,
> Daniel
>
>
> 1Rnwb wrote:
>>
>> Hello Gurus
>> I have two correlation matrices 'xa' and 'xb'
>> set.seed(100)
>> d=cbind(x=rnorm(20)+1,
>> x1=rnorm(20)+1,
>> x2=rnorm(20)+1)
>>
>>
>> d1=cbind(x=rnorm(20)+2,
>> x1=rnorm(20)+2,
>> x2=rnorm(20)+2)
>>
>> xa=cor(d,use='complete')
>>
>> xb=cor(d1,use='complete')
>>
>>
>>
>> I want to combine these two to get a third matrix which should have half
>> values from 'xa' and half values from 'xb'
>>            x         x1         x2
>> x  1.0000000  -0.15157123 -0.23085308
>> x1 0.3466155 1.00000000  -0.01061675
>> x2 0.1234507 0.01775527 1.00000000
>>
>> I would like to generate a heatmap for correlation values in disease and
>> non disease phenotype
>>
>> I would appreciate if someone can point me in correct direction.
>> Thanks
>> sharad
>>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/correlation-matrix-tp3891085p3891685.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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