Skip to contents

This function converts trait data from the external TRY database into the tabular format required by the PEcAn meta-analysis module.

Usage

format_try_for_ma(
  try_data,
  trait_map = try_trait_mapping(),
  species_map = NULL
)

Arguments

try_data

A data frame containing data from the TRY database.

trait_map

A named character vector for mapping TRY TraitName to PEcAn vname. Names should be TRY TraitName and values should be PEcAn vname. Defaults to `try_trait_mapping()`.

species_map

An optional named vector mapping TRY `SpeciesName` to PEcAn BETY `specie_id`. If provided, this is used to assign `specie_id` instead of using the raw `AccSpeciesID`. If omitted, the returning data will include a `species_name` column to help users map PFTs later.

Value

A data frame formatted similarly to BETYdb output to be passed to `PEcAn.MA::jagify`.

Details

The resulting data frame is in the format returned by the PEcAn database (`PEcAn.DB::query.traits()`). To be used in `pecan.ma()`, **it must first be run through the `jagify()` function** to ensure all missing values and columns are appropriately processed, as the meta-analysis model requires data converted into specific distributions and error formats. `jagify` will drop unused TRY-specific columns and compute the final `obs.prec` values.