prepare_data_for_fit()
prepare_data_for_fit | R Documentation |
Prepare Data for Model Fitting
Description
Prepares community or abiotic data for model fitting by reshaping it into a wide format with appropriate column names.
Usage
prepare_data_for_fit(data = NULL, type = c("community", "abiotic"))
Arguments
data
|
A data frame containing the input data. For ‘type = "community"’, it must include columns ‘dataset_name’, ‘age’, ‘taxon’, and ‘pollen_prop’. For ‘type = "abiotic"’, it must include columns ‘dataset_name’, ‘age’, ‘abiotic_variable_name’, and ‘abiotic_value’. |
type
|
A character string specifying the type of data to prepare. Must be either "community" or "abiotic" (default: "community"). |
Details
The function validates the input data and reshapes it based on the specified ‘type’. For community data, it combines ‘dataset_name’ and ‘age’ into a ‘sample_name’ column, selects relevant columns, and pivots the data to a wide format. For abiotic data, it performs similar steps but uses abiotic variable names and values.
Value
A data frame in wide format, with ‘sample_name’ as row names and either taxa or abiotic variable names as columns. For community data, missing values are filled with 0. For abiotic data, missing values are left as NA.