Skip to contents

Easily output a correlation matrix and export it to Microsoft Excel, with the first row and column frozen, and correlation coefficients colour-coded based on their effect size (0.0-0.2: small (no colour); 0.2-0.4: medium (pink); 0.4-1.0: large (red)).

Usage

cormatrix_excel_deprecated(
  data,
  filename,
  overwrite = TRUE,
  use = "pairwise.complete.obs"
)

Arguments

data

The data frame

filename

Desired filename (path can be added before hand but no need to specify extension).

overwrite

Whether to allow overwriting previous file.

use

How to handle NA (see ?cor for options).

Value

A Microsoft Excel document, containing the colour-coded correlation matrix.

Examples

# \donttest{
.old_wd <- setwd(tempdir())
# Basic example
cormatrix_excel_deprecated(mtcars, "cormatrix")
#>        mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#> mpg   1.00 -0.85 -0.85 -0.78  0.68 -0.87  0.42  0.66  0.60  0.48 -0.55
#> cyl  -0.85  1.00  0.90  0.83 -0.70  0.78 -0.59 -0.81 -0.52 -0.49  0.53
#> disp -0.85  0.90  1.00  0.79 -0.71  0.89 -0.43 -0.71 -0.59 -0.56  0.39
#> hp   -0.78  0.83  0.79  1.00 -0.45  0.66 -0.71 -0.72 -0.24 -0.13  0.75
#> drat  0.68 -0.70 -0.71 -0.45  1.00 -0.71  0.09  0.44  0.71  0.70 -0.09
#> wt   -0.87  0.78  0.89  0.66 -0.71  1.00 -0.17 -0.55 -0.69 -0.58  0.43
#> qsec  0.42 -0.59 -0.43 -0.71  0.09 -0.17  1.00  0.74 -0.23 -0.21 -0.66
#> vs    0.66 -0.81 -0.71 -0.72  0.44 -0.55  0.74  1.00  0.17  0.21 -0.57
#> am    0.60 -0.52 -0.59 -0.24  0.71 -0.69 -0.23  0.17  1.00  0.79  0.06
#> gear  0.48 -0.49 -0.56 -0.13  0.70 -0.58 -0.21  0.21  0.79  1.00  0.27
#> carb -0.55  0.53  0.39  0.75 -0.09  0.43 -0.66 -0.57  0.06  0.27  1.00
#> 
#>  [Correlation matrix 'cormatrix.xlsx' has been saved to working directory (or where specified).]
setwd(.old_wd)
# }