r - Creating correlation matrix p values -
this question has answer here:
- how iterate through parameters analyse 2 answers
i can correlation matrix using following commands:
> df<-data.frame(x=c(5,6,5,9,4,2,1,3,5,7),y=c(3.1,2.5,3.8,5.4,6.5,2.5,1.5,8.1,7.1,6.1),z=c(5,6,4,9,2,4,1,6,2,4)) > cor(df) x y z x 1.0000000 0.2923939 0.6566866 y 0.2923939 1.0000000 0.1167084 z 0.6566866 0.1167084 1.0000000 > i can individual p-values using command:
> cor.test(x,y)$p.value [1] 0.4123234 how can matrix of p-values these correlation coefficients? help.
you can use package hmisc.
an example of how works:
cor <- rcorr(as.matrix(data), type="pearson") cor$r shows correlation matrix, cor$p matrix corresponding p-values.
Comments
Post a Comment