correlation_matrix: correlation matrix

View source: R/correlation_matrix.R

correlation_matrixR Documentation

correlation matrix

Description

Creates a correlation matrix

Usage

correlation_matrix(
  data = NULL,
  var_names = NULL,
  row_var_names = NULL,
  col_var_names = NULL,
  round_r = 2,
  round_p = 3,
  output_type = "r"
)

Arguments

data

a data object (a data frame or a data.table)

var_names

names of the variables for which to calculate all pairwise correlations

row_var_names

names of the variables that will go on the rows of the correlation matrix

col_var_names

names of the variables that will go on the columns of the correlation matrix

round_r

number of decimal places to which to round correlation coefficients (default = 2)

round_p

number of decimal places to which to round p-values (default = 3)

output_type

which value should be filled in cells of the correlation matrix? If output_type = "r", correlation coefficients; if output_type = "p", p-values; if output_type = "rp", correlation coefficients with significance symbols based on p-values; if output_type = "n", sizes of the samples used to calculate the correlation coefficients

Value

the output will be a correlation matrix in a data.table format

Examples

correlation_matrix(data = mtcars, var_names = c("mpg", "cyl", "wt"))
correlation_matrix(data = mtcars,
row_var_names = c("mpg", "cyl", "hp"), col_var_names = c("wt", "am"))

kim documentation built on Oct. 9, 2023, 5:08 p.m.