library(knitr)
Yes, the correlation
function from the psycho
package.
# devtools::install_github("neuropsychology/psycho.R") # Install the newest version library(psycho) library(tidyverse) cor <- psycho::affective %>% correlation()
This function automatically select numeric variables and run a correlation analysis. It returns a psychobject
.
We can then extract a formatted table that can be saved and pasted into reports and manuscripts by using the summary
function.
summary(cor) # write.csv(summary(cor), "myformattedcortable.csv")
knitr::kable(summary(cor))
It integrates a plot done with ggcorplot
.
plot(cor)
It also includes a pairwise correlation printing method.
print(cor)
You can also cutomize the type (pearson, spearman or kendall), the p value correction method (holm (default), bonferroni, fdr, none...) and run partial, semi-partial or glasso correlations.
psycho::affective %>% correlation(method = "pearson", adjust="bonferroni", type="partial") %>% summary()
psycho::affective %>% correlation(method = "pearson", adjust="bonferroni", type="partial") %>% summary() %>% knitr::kable()
In order to prevent people for running many uncorrected correlation tests (promoting p-hacking and result-fishing), we included the i_am_cheating
parameter. If FALSE (default), the function will help you finding interesting results!
df_with_11_vars <- data.frame(replicate(11, rnorm(1000))) cor <- correlation(df_with_11_vars, adjust="none") summary(cor)
knitr::kable(summary(cor)[,1:11])
As we can see, Schopenhauer's Optimism is strongly related to many variables!!!
This package was useful? You can cite psycho
as follows:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.