SQL applying the mass-preserving factors to a merge-input relation
Source:R/density_cal.R
density_calibrate_sql.RdWraps a SELECT carrying at least ms_merge_key, ds_key, val so the rows of the density datasets are
scaled by their taxon's factor and capped at 100; every other row, and every other column (mkey_id,
cell_id, ...), passes through unchanged (m.* REPLACE). A taxon without a factor row keeps its survey
values (f = 1).
Arguments
- sql
character; the merge-input SELECT (
ms_merge_key, ds_key, val+ any other columns).- dens_ds
character vector; the density dataset keys (e.g.
c("gm", "nc", "cce")).- factors
character; the relation
density_cal_factors_sql()produced (ms_merge_key, f).