hib_calc_site_contrasts: Calculate differences between sites for a range of environmental variables.
Source:R/hib_site_contrasts.R
hib_calc_site_contrasts.RdThis function calculates measures of differences between sites within a study,
which can then be used as covariates in models of compositional dis/similarity.
A data.frame (named site_contrasts) containing the site-contrast pairs
(SSBS1, SSBS2) and the associated 'differences' is added to the provided
HibDatabase.
Usage
hib_calc_site_contrasts(
obj,
metrics,
custom_metric_specs = NULL,
baseline_lui = "Primary vegetation_Minimal use",
overwrite = FALSE
)Arguments
- obj
A
HibDatabaseobject.- metrics
A
charactervector of 'distance' metrics. Current options are; "lui_contrast", "geogr_dist_hav", "geogr_dist_geod" and "geogr_midpoint", "env_dist".- custom_metric_specs
A named
list(orNULL) with each named item containing the specifications for the named custom metric. At present, custom metrics must be based onvegdistdistance metrics.
Essential named values within the specifications of a custom metric are:dist_metr- a character indicating the metric of choice;vars- a character vector indicating the site variables to use when calculating the distance metric.
For example:
list(Gower_dist_a = list(dist_metr = "gower", vars = c("env1", "env2", "env3")), Gower_dist_b = list(dist_metr = "gower", vars = c("env4", "env5", "env6")))
Metric names (as specified in the name of the sub-lists) will be converted to sentence-case in the output data.- baseline_lui
A
character(can be multiple entries) orNULL, indicating the baseline LUI/s against which differences are calculated per study. Value/s provided should match the value/s used when calculating compositional dis/similarity (hib_calc_div_between).- overwrite
A
logicalindicating whether or not any current site contrast data should be over-written. Default value isFALSE.
Details
The function currently returns site1-site2 contrasts for all within-study contrasts
where site1 has the baseline_lui. Subsequent, filtering to ensure contrasts
are based on the same effort level is recommended and may be incrporated in
future releases.
Examples
if (FALSE) { # \dontrun{
obj <- hib_calc_site_contrasts(obj,
c("lui_contrast", "geogr_dist_hav"),
baseline_lui = "Primary vegetation_Minimal use")
} # }