diff --git a/R/ggcorrplot.R b/R/ggcorrplot.R index 52323bf..529ad2e 100644 --- a/R/ggcorrplot.R +++ b/R/ggcorrplot.R @@ -9,16 +9,22 @@ ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all"){ mpval<-mpval[order$y, order$x] df<-mcor %>% as.data.frame() - if (tri == "lower"){ + if (tri == "upper"){ df[lower.tri(df, diag=F)]<-NA } + if (tri == "lower"){ + df[upper.tri(df, diag=F)]<-NA + } df<-df %>% add_column(Var1=rownames(mcor),.before=1) %>% gather(Var2, Value, -Var1) %>% filter(!is.na(Value)) df.pval<-mpval %>% as.data.frame() - if (tri == "lower"){ + if (tri == "upper"){ df.pval[lower.tri(df.pval, diag=F)]<-NA } + if (tri == "lower"){ + df.pval[upper.tri(df.pval, diag=F)]<-NA + } df.pval<-df.pval %>% add_column(Var1=rownames(mpval),.before=1) %>% gather(Var2, Value, -Var1) %>% filter(!is.na(Value))