From cb575ac29733fed8bcca28d038fdafc4c7a10a32 Mon Sep 17 00:00:00 2001 From: Marcel Costa Date: Sun, 6 Feb 2022 08:40:51 +0100 Subject: [PATCH] =?UTF-8?q?Arreglando=20la=20funci=C3=B3n=20ggcorrplot,=20?= =?UTF-8?q?que=20siempre=20llamaba=20a=20las=20columnas=20Cyt=20y=20Value.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/ggcorrplot.R | 5 +++-- man/ggcorrplot.Rd | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/ggcorrplot.R b/R/ggcorrplot.R index c928eb5..1880ded 100644 --- a/R/ggcorrplot.R +++ b/R/ggcorrplot.R @@ -1,5 +1,6 @@ -ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all", method="pearson"){ - m.df<-df %>% spread(Cyt, Value) %>% select(-pats) +ggcorrplot<-function(df, var, value,color="#FFFFFF00", stat="signif", tri="all", method="pearson"){ + allnames<-colnames(df) + m.df<-df %>% spread(all_of(var), all_of(value)) %>% select(!any_of(allnames)) mcor<-cor(m.df, m.df, use="pairwise.complete.obs", method = method) # Por defecto usa el método de Pearson. mpval<-Hmisc::rcorr(as.matrix(m.df), type=method)$P diff --git a/man/ggcorrplot.Rd b/man/ggcorrplot.Rd index b5ec687..e296641 100644 --- a/man/ggcorrplot.Rd +++ b/man/ggcorrplot.Rd @@ -2,11 +2,12 @@ \alias{ggcorrplot} \title{ggcorrplot} \usage{ -ggcorrplot(df, var, color="#FFFFFF00", stat="signif", tri="all", method="pearson") +ggcorrplot(df, var, value, color="#FFFFFF00", stat="signif", tri="all", method="pearson") } \arguments{ \item{df}{A data frame in "long" format.} \item{var}{The column that will be used to analyze correlation all against all.} + \item{value}{The column that will be used as numeric data to analyze correlation.} \item{color}{The color of the lines of geom_tile (the border). By default, its transparent.} \item{stat}{The stats that will be on the tiles. They can be "signif", "pval", "none". By default, it presents "signif" (stars representing pvalue).} \item{tri}{It specifies which half of the correlation matrix is shown. Can be "all" (the default), "upper" or "lower".} @@ -25,5 +26,5 @@ df<-data.frame("pats"=paste0("PAT", 1:20), "CytA"=rnorm(20,5), "CytB"=rnorm(20,5 df<-gather(df, Cyt, Value,-pats) head(df) -ggcorrplot(df, Cyt) +ggcorrplot(df, Cyt, Value) }