create_data_matrices.RdOften multi-trait data will be provided in tall format with a single value per row, and individuals represented on multiple rows. MegaLMM expects the data to be in wide format with all observations on the same individual in a row, and only one row per individual.
create_data_matrices(tall_data, id_cols, names_from, values_from, ...)data.frame in the tall format
vector of strings representing the set of columns of tall_data
necessary to uniquely specify a single individual. See tidyr::pivot_wider.
vector of strings representing the set of columns of tall_data
necessary to uniquely specify a single trait See tidyr::pivot_wider.
string giving the column of tall_data with the observations.
additional parameters passed to tidyr::pivot_wider.
list with elements:
* data a data.frame with the elements of id_cols
* Y a numeric matrix of the traits
* trait_info a data.frame with 1 row per trait and columns from names_from
Specifically, the input to setup_model_MegaLMM expect Y, a
nxp matrix for n individuals and p traits (Missing values coded as NA
are fine in Y), and data, a data.frame with the variables used in formula.
This function takes the tall format data and pivots it using the tidyr::pivot_wider
function, returning the Y and data objects necessary to set up a
MegaLMM model