
Helper function to read in data
df_to_corr.RdThis function builds a list of correlation matrices from data that are in flat files where a correlation matrix is coded into a single row, a common format for coding correlation matrices.
Arguments
- data
Data frame input used to convert to correlation matrices.
- variables
A character vector of variable names representing the columns to convert to a pairwise correlation matrix. Variable names take the following format: "columnname_rowname" where the name prior to the underscore is the column name and the name after the underscore is the row name.
- ID
A variable name, as a character string, to use as names for the list elements.
Details
Each supplied pair name is mapped to its actual matrix coordinates;
column order does not change pair identity. Supply every distinct pair once,
with values in [-1,1] or NA. Variable names must not contain underscores;
exactly one underscore separates the two variable names. Missing entries are
retained for downstream synthesis. An ID column is optional and supplies list
names; correlation synthesis itself requires independent, distinct study IDs.
Examples
becker09 <- read.csv(paste0(system.file('raw_data', package = 'mars'),
'/Becker09.csv'))
becker09_list <- df_to_corr(becker09,
variables = c('Cognitive_Performance',
'Somatic_Performance',
'Selfconfidence_Performance',
'Somatic_Cognitive',
'Selfconfidence_Cognitive',
'Selfconfidence_Somatic'),
ID = 'ID')