reshape_mat2dat | R Documentation |
This function is designed to extract data from a correlation matrix that is in the format commonly published in journals, with leading columns of construct names and descriptive statistics being listed along with correlation data.
reshape_mat2dat(
var_names,
cor_data,
common_data = NULL,
unique_data = NULL,
diag_label = NULL,
lower_tri = TRUE,
data = NULL
)
var_names |
Vector (or scalar column name to match with |
cor_data |
Square matrix (or vector of column names to match with |
common_data |
Vector or matrix (or vector of column names to match with |
unique_data |
Vector or matrix (or vector of column names to match with |
diag_label |
Optional name to attribute to values extracted from the diagonal of the matrix (if NULL, no values are extracted from the diagonal). |
lower_tri |
Logical scalar that identifies whether the correlations are in the lower triangle ( |
data |
Matrix or data frame containing study data (when present, column names of |
Long-format data frame of correlation data, variable names, and supporting information
Jack W. Kostal
## Create a hypothetical matrix of data from a small study:
mat <- data.frame(var_names = c("X", "Y", "Z"),
n = c(100, 100, 100),
mean = c(4, 5, 3),
sd = c(2.4, 2.6, 2),
rel = c(.8, .7, .85),
reshape_vec2mat(cov = c(.3, .4, .5)))
## Arguments can be provided as quoted characters or as the unquoted names of `data`'s columns:
reshape_mat2dat(var_names = var_names,
cor_data = c("Var1", "Var2", "Var3"),
common_data = "n",
unique_data = c("mean", "sd", "rel"),
data = mat)
## Arguments can also provided as raw vectors, matrices, or data frames, without a data argument:
reshape_mat2dat(var_names = mat[,1],
cor_data = mat[,6:8],
common_data = mat[,2],
unique_data = mat[,3:5])
## If data is not null, arguments can be a mix of matrix/data frame/vector and column-name arguments
reshape_mat2dat(var_names = mat[,1],
cor_data = mat[,6:8],
common_data = "n",
unique_data = c("mean", "sd", "rel"),
data = mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.