Browse Source

Corrigiendo el orden de la triangulación.

main
Costa 2 years ago
parent
commit
0281fa95c8
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      R/ggcorrplot.R

+ 5
- 2
R/ggcorrplot.R

@ -3,6 +3,11 @@ ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all"){
mcor<-cor(m.df, m.df, use="pairwise.complete.obs") # Por defecto usa el método de Pearson. mcor<-cor(m.df, m.df, use="pairwise.complete.obs") # Por defecto usa el método de Pearson.
mpval<-Hmisc::rcorr(as.matrix(m.df))$P mpval<-Hmisc::rcorr(as.matrix(m.df))$P
order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
mor<-mcor[order$y, order$x]
mpval<-mpval[order$y, order$x]
df<-mcor %>% as.data.frame() df<-mcor %>% as.data.frame()
if (tri == "lower"){ if (tri == "lower"){
df[lower.tri(df, diag=T)]<-NA df[lower.tri(df, diag=T)]<-NA
@ -23,8 +28,6 @@ ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all"){
df.pval$Value<-gtools::stars.pval(df.pval$Value) df.pval$Value<-gtools::stars.pval(df.pval$Value)
} }
order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
df$Var1<-factor(df$Var1, levels=order$x) df$Var1<-factor(df$Var1, levels=order$x)
df$Var2<-factor(df$Var2, levels=order$y) df$Var2<-factor(df$Var2, levels=order$y)

Loading…
Cancel
Save