View source: R/helper_functions.R
create_data_matrices | R Documentation |
Often 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, ...)
tall_data |
data.frame in the tall format |
id_cols |
vector of strings representing the set of columns of |
names_from |
vector of strings representing the set of columns of |
values_from |
string giving the column of |
... |
additional parameters passed to |
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
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.