Harmonize treatments, units, and expected cropping sequences
harmonize_treatments_units_crops.RdThis function combines data from multiple experimental design database tables into a combined table with the experimental treatment components, rotation phases, and expected crops for every unit_id and year.
Arguments
- db
A named list containing the database tables "treatment_id_info","treatment_id_components","experimental_unit_info", "experimental_unit_treatments","rotation_phases", and "rotation_id_info". If the list is not supplied, it will be imported from Directus (assuming a valid token as been set).
- includeMixComponents
TRUE or FALSE indicating whether components of crop mixtures should be included. If TRUE, the output dataframe will have separate rows for the crop mixture (e.g., crop_id = perennial mix) and the crop mixture. These are identified in the columns is_a_mix and is_a_mix_component from the rotation_phases table. Mix components are identified separately in the planting_info table for seeding rates.
- maxyear
Which year to use as the end year for ongoing experiments. The default is 2022.
Value
A data-frame with one row per unit_id/year/crop that includes treatmentIDs, treatment components, and information from the rotation_phases table. The crop_id column from rotation_phases is renamed expected_crop_id. The output includes planting_year and harvest_year, as in the yield, harvest, and planting data tables. There is another column, mergeYear, that indicates the year used to merge crop-phase data with treatment data (usually the harvest year, except for over-winter cover crops that extend into the following calendar year).