cortable: Correlation plot and table with significance stars.

Description Usage Arguments Details Value Author(s) Examples

Description

Get a correlation plot and table with significance stars.

Usage

1
2
3
4
5
cortable(df,
        returns="both",
        correction="holm",
        type="pearson",
        iamaboringperson=FALSE)

Arguments

df

A dataframe.

returns

"table", "plot" or "both". Returns a table, a ggplot plot or a list with both.

correction

"none", "holm" for holm-bonferroni (default), "fdr" for False Discovery Rate.

type

"pearson" for Pearson's, "partial" for partial correlations and "spearman" for Spearman's.

iamaboringperson

Are you?

Details

cortable displays a correlation matrix or table, and a plot. Note that you can save the table under a .csv format to easily integrate it in your documents. Moreover, you can customize the plot's theme and featuers as it is in ggplot2's format.

Value

result

Either The table in the format of a dataframe or the plot in the format of a ggplot's plot. Depending on the "returns" argument.

Author(s)

Dominique Makowski and Bertolt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
require(neuropsychology)

df <- personality

cortable(df)

# Extract the table
table <- cortable(df, returns="table")

# Extract the plot
plot <- cortable(df, returns="plot")

# Save table
write.csv(table, "correlation_table.csv")

# Save plot
ggplot2::ggsave("mycorrplot.png", plot)

Example output

Loading required package: tidyverse
Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages ---------------------------------------------------
filter(): dplyr, stats
lag():    dplyr, stats
************
Welcome to neuropsychology v0.5.0 (c) Dominique Makowski.
See documentation on https://www.rdocumentation.org/packages/neuropsychology
Do not hesitate to create an issue on https://github.com/neuropsychology/neuropsychology.R/issues with questions, comments, or movie recommendations.
************
$table
                                      Age   Salary Study_Level    BMI
Age                                  <NA>     <NA>        <NA>   <NA>
Salary                            0.56***     <NA>        <NA>   <NA>
Study_Level                       0.12**   0.23***        <NA>   <NA>
BMI                               0.30***  0.20***       0.02    <NA>
Extraversion                       -0.06     0.03        0.01   0.01 
Empathy.Agreeableness              -0.03    -0.08        0.01  -0.09 
Conscientiousness                 0.14***    0.06        0.00  -0.03 
Instability.Neuroticism            -0.08    -0.11       -0.08   0.00 
Openness_to_Experience.Intellect   -0.09   -0.13*        0.05  -0.05 
Honesty.Humility                    0.06    -0.06        0.05  -0.06 
Disinhibition                      -0.05    -0.01       -0.07   0.00 
Detachment                         -0.02    -0.08       -0.07   0.03 
Psychoticism                     -0.18*** -0.14**     -0.14*** -0.01 
Negative_Affect                  -0.20*** -0.16***     -0.10*  -0.04 
Antagonism                         -0.04     0.04        0.01   0.01 
                                 Extraversion Empathy.Agreeableness
Age                                      <NA>                  <NA>
Salary                                   <NA>                  <NA>
Study_Level                              <NA>                  <NA>
BMI                                      <NA>                  <NA>
Extraversion                             <NA>                  <NA>
Empathy.Agreeableness                 0.13***                  <NA>
Conscientiousness                      -0.09                  0.00 
Instability.Neuroticism               0.11**                 -0.03 
Openness_to_Experience.Intellect      0.15***               0.19***
Honesty.Humility                       -0.08                0.27***
Disinhibition                         0.22***                -0.07 
Detachment                           -0.28***              -0.24***
Psychoticism                            0.00                 -0.07 
Negative_Affect                        -0.03                0.15***
Antagonism                            0.14***              -0.23***
                                 Conscientiousness Instability.Neuroticism
Age                                           <NA>                    <NA>
Salary                                        <NA>                    <NA>
Study_Level                                   <NA>                    <NA>
BMI                                           <NA>                    <NA>
Extraversion                                  <NA>                    <NA>
Empathy.Agreeableness                         <NA>                    <NA>
Conscientiousness                             <NA>                    <NA>
Instability.Neuroticism                    -0.11*                     <NA>
Openness_to_Experience.Intellect          -0.14***                  -0.02 
Honesty.Humility                             0.05                 -0.16***
Disinhibition                             -0.35***                 0.27***
Detachment                                -0.13***                 0.22***
Psychoticism                              -0.24***                 0.26***
Negative_Affect                             -0.09                  0.55***
Antagonism                                 -0.10*                  0.21***
                                 Openness_to_Experience.Intellect
Age                                                          <NA>
Salary                                                       <NA>
Study_Level                                                  <NA>
BMI                                                          <NA>
Extraversion                                                 <NA>
Empathy.Agreeableness                                        <NA>
Conscientiousness                                            <NA>
Instability.Neuroticism                                      <NA>
Openness_to_Experience.Intellect                             <NA>
Honesty.Humility                                          0.15***
Disinhibition                                             0.14***
Detachment                                                 -0.01 
Psychoticism                                              0.21***
Negative_Affect                                            -0.07 
Antagonism                                                  0.04 
                                 Honesty.Humility Disinhibition Detachment
Age                                          <NA>          <NA>       <NA>
Salary                                       <NA>          <NA>       <NA>
Study_Level                                  <NA>          <NA>       <NA>
BMI                                          <NA>          <NA>       <NA>
Extraversion                                 <NA>          <NA>       <NA>
Empathy.Agreeableness                        <NA>          <NA>       <NA>
Conscientiousness                            <NA>          <NA>       <NA>
Instability.Neuroticism                      <NA>          <NA>       <NA>
Openness_to_Experience.Intellect             <NA>          <NA>       <NA>
Honesty.Humility                             <NA>          <NA>       <NA>
Disinhibition                            -0.17***          <NA>       <NA>
Detachment                               -0.17***       0.26***       <NA>
Psychoticism                             -0.19***       0.48***    0.45***
Negative_Affect                          -0.17***       0.21***    0.26***
Antagonism                               -0.46***       0.33***    0.27***
                                 Psychoticism Negative_Affect
Age                                      <NA>            <NA>
Salary                                   <NA>            <NA>
Study_Level                              <NA>            <NA>
BMI                                      <NA>            <NA>
Extraversion                             <NA>            <NA>
Empathy.Agreeableness                    <NA>            <NA>
Conscientiousness                        <NA>            <NA>
Instability.Neuroticism                  <NA>            <NA>
Openness_to_Experience.Intellect         <NA>            <NA>
Honesty.Humility                         <NA>            <NA>
Disinhibition                            <NA>            <NA>
Detachment                               <NA>            <NA>
Psychoticism                             <NA>            <NA>
Negative_Affect                       0.35***            <NA>
Antagonism                            0.40***         0.25***

$plot

Saving 6.67 x 6.67 in image

neuropsychology documentation built on May 2, 2019, 2:13 p.m.