Query priors using prepared statements

query_priors(
  pft_names = NULL,
  traits = NULL,
  pft_ids = NULL,
  expand = TRUE,
  strict = FALSE,
  ...
)

Arguments

pft_names

Character vector of PFT names (`name` column of BETY `pfts` table). You cannot pass both this and `pft_ids`.

traits

Character vector of trait names (`name` column of BETY `traits` table). If `NULL` (default), return information for all traits available for that PFT.

pft_ids

Numeric vector of PFT IDs (`id` column of BETY `pfts` table). You cannot pass both this and `pft_names`.

expand

(Logical) If `TRUE` (default), search every trait-PFT combination. If `FALSE`, assume that input traits and PFTs are paired.

strict

(Logical) If `TRUE`, throw an error if any of the input `pft_names/ids` or `traits` are missing from the output. If `FALSE` (default), only throw a warning.

...

Additional arguments to [db.query()]

Value

`data.frame` containing prior information for the given PFTs and traits.

Examples

if (FALSE) { # \dontrun{
  con <- db.open(...)

  # No trait provided, so return all available traits
  pdat <- query_priors(
    c("temperate.Early_Hardwood", "temperate.North_Mid_Hardwood",
      "temperate.Late_Hardwood"),
    con = con
  )

  # Traits provided, so restrict to only those traits. Note that
  # because `expand = TRUE`, this will search for these traits for
  # every PFT.
  pdat2 <- query_priors(
    c("Optics.Temperate_Early_Hardwood",
      "Optics.Temperate_Mid_Hardwood",
      "Optics.Temperate_Late_Hardwood"),
    c("leaf_reflect_vis", "leaf_reflect_nir"),
    con = con
  )

  # With `expand = FALSE`, search the first trait for the first PFT,
  # the second trait for the second PFT, etc. Note that this means
  # PFT and trait input vectors must be the same length.
  pdat2 <- query_priors(
    c("Optics.Temperate_Early_Hardwood",
      "Optics.Temperate_Early_Hardwood",
      "Optics.Temperate_Mid_Hardwood",
      "Optics.Temperate_Late_Hardwood"),
    c("leaf_reflect_vis",
      "leaf_reflect_nir",
      "leaf_reflect_vis",
      "leaf_reflect_nir"),
    con = con
  )
} # }