Display a Correlation Matrix Table in the Console
Arguments
- display
A
corr_specobject fromnew_corr_data(), or a plain symmetric matrix (e.g. fromcor()).- title
Label shown in the title (e.g.
"Pearson Correlation Matrix"). Auto-detected from atitleattribute on the spec if present.- diag_1
If
TRUE, diagonal cells always show"1". DefaultTRUE.- digits
Decimal places for numeric formatting. Default
3.- layout_view
Show a layout legend box above the table? Default
FALSE.- layout_center
Center the layout box in the terminal? Default
FALSE.- center_table
Center table in terminal? Default
FALSE.- border_char
Border character. Default from
getOption("tab_default").- style
A
cm_style()object. Keys match the extra field names passed tonew_corr_data()(e.g.rho,pval,bf), plustitleandborder_text.- ...
Reserved for future use.
Examples
# From a plain correlation matrix, e.g. using `cor()`
corr_matrix(cor(mtcars[, 1:4]), title = "Pearson Correlation Matrix")
#>
#> Pearson Correlation Matrix
#> ────────────────────────────────────────────────
#> Variable mpg cyl disp hp
#> ────────────────────────────────────────────────
#> mpg 1 -0.852 -0.848 -0.776
#> ────────────────────────────────────────────────
#> cyl -0.852 1 0.902 0.832
#> ────────────────────────────────────────────────
#> disp -0.848 0.902 1 0.791
#> ────────────────────────────────────────────────
#> hp -0.776 0.832 0.791 1
#> ────────────────────────────────────────────────
# Customizable example
spec = new_corr_data(
var1 = c("a", "a", "b"),
var2 = c("b", "c", "c"),
rho = c("0.89", "0.79", "0.66"),
pval = c("<0.001", "<0.001", "<0.001")
)
corr_matrix(spec, title = "Pearson Correlation Matrix", layout_view = TRUE)
#>
#> ┌───────────────────────────┐
#> | Layout for Corr. Matrix |
#> ├───────────────────────────┤
#> | < rho > |
#> | < pval > |
#> └───────────────────────────┘
#>
#>
#> Pearson Correlation Matrix
#> ──────────────────────────────────
#> Variable a b c
#> ──────────────────────────────────
#> a
#>
#> ──────────────────────────────────
#> b 0.89
#> <0.001
#> ──────────────────────────────────
#> c 0.79 0.66
#> <0.001 <0.001
#> ──────────────────────────────────
