Reads a data frame and presents Pearson correlations above the diagonal and Spearman correlations below.

prepare_correlation_table(df, digits = 2, bold = 0.05, format = "html", ...)

Arguments

df

Data frame containing at least two variables that are either numeric or logical and at least five observations.

digits

The number of digits that you want to report.

bold

Indicate the p-Value for for identifying significant correlations in bold print. Defaults to 0.05. If set to 0, no bold print is being used.

format

The format that you want kable to produce ("html" or "latex")

...

Additional parameters that are passed on to kable

Value

A list containing four items:

"df_corr"

A data frame containing the correlations

"df_prob"

A data frame containing the p-values of the correlations

"df_n"

A data frame containing the number of observations used for the correlations

"kable_ret"

The return value provided by kable containing the formatted table

Examples

t <- prepare_correlation_table(mtcars) t$df_corr
#> mpg cyl disp hp drat wt #> mpg 1.0000000 -0.8521620 -0.8475514 -0.7761684 0.68117191 -0.8676594 #> cyl -0.9108013 1.0000000 0.9020329 0.8324475 -0.69993811 0.7824958 #> disp -0.9088824 0.9276516 1.0000000 0.7909486 -0.71021393 0.8879799 #> hp -0.8946646 0.9017909 0.8510426 1.0000000 -0.44875912 0.6587479 #> drat 0.6514555 -0.6788812 -0.6835921 -0.5201250 1.00000000 -0.7124406 #> wt -0.8864220 0.8577282 0.8977064 0.7746767 -0.75039041 1.0000000 #> qsec 0.4669358 -0.5723509 -0.4597818 -0.6666060 0.09186863 -0.2254012 #> vs 0.7065968 -0.8137890 -0.7236643 -0.7515934 0.44745745 -0.5870162 #> am 0.5620057 -0.5220712 -0.6240677 -0.3623276 0.68657079 -0.7377126 #> gear 0.5427816 -0.5643105 -0.5944703 -0.3314016 0.74481617 -0.6761284 #> carb -0.6574976 0.5800680 0.5397781 0.7333794 -0.12522294 0.4998120 #> qsec vs am gear carb #> mpg 0.41868403 0.6640389 0.59983243 0.4802848 -0.55092507 #> cyl -0.59124207 -0.8108118 -0.52260705 -0.4926866 0.52698829 #> disp -0.43369788 -0.7104159 -0.59122704 -0.5555692 0.39497686 #> hp -0.70822339 -0.7230967 -0.24320426 -0.1257043 0.74981247 #> drat 0.09120476 0.4402785 0.71271113 0.6996101 -0.09078980 #> wt -0.17471588 -0.5549157 -0.69249526 -0.5832870 0.42760594 #> qsec 1.00000000 0.7445354 -0.22986086 -0.2126822 -0.65624923 #> vs 0.79157148 1.0000000 0.16834512 0.2060233 -0.56960714 #> am -0.20333211 0.1683451 1.00000000 0.7940588 0.05753435 #> gear -0.14819967 0.2826617 0.80768800 1.0000000 0.27407284 #> carb -0.65871814 -0.6336948 -0.06436525 0.1148870 1.00000000