Biological Condition Gradient fuzzy membership for metrics.
BCG.Metric.Membership(
df.metrics,
df.rules,
input.shape = "wide",
col_SAMPLEID = "SAMPLEID",
col_INDEX_NAME = "INDEX_NAME",
col_INDEX_CLASS = "INDEX_CLASS",
col_LEVEL = "LEVEL",
col_METRIC_NAME = "METRIC_NAME",
col_RULE_TYPE = "RULE_TYPE",
col_LOWER = "LOWER",
col_UPPER = "UPPER",
col_METRIC_VALUE = "METRIC_VALUE",
col_INCREASE = "INCREASE",
...
)Wide data frame with metric values to be evaluated.
Data frame of metric thresholds to check.
Shape of df.metrics; wide or long. Default is wide.
Column name for sample id. Default = "SAMPLEID"
Column name for index name. Default = "INDEX_NAME"
Column name for index class Default = "INDEX_CLASS"
Column name for level. Default = "LEVEL"
Column name for metric name. Default = "METRIC_NAME"
Column name for rule type (e.g., Rule0). Default = "RULE_TYPE"
Column name for lower limit. Default = "LOWER"
Column name for upper limit. Default = "UPPER"
Column name for metric value. Default = "METRIC_VALUE"
Column name for if the metric value increases. Default = "INCREASE"
Arguments passed to `BCG.MetricMembership` used internally
Returns a data frame of results in the long format.
Converts metric values into BCG membership values. Uses a rules table to define the metrics, scoring range, and direction for each named index.
Deprecated col_SITE_TYPE for col_INDEX_CLASS in v2.0.0.9001.
# library(readxl)
# library(BioMonTools)
# Calculate Metrics
df_samps_bugs <- readxl::read_excel(
system.file("extdata/Data_BCG_PugLowWilVal.xlsx"
, package = "BCGcalc")
, guess_max = 10^6)
myDF <- df_samps_bugs
myCols <- c("Area_mi2", "SurfaceArea", "Density_m2", "Density_ft2")
# populate missing columns prior to metric calculation
col_missing <- c("INFRAORDER", "HABITAT", "ELEVATION_ATTR", "GRADIENT_ATTR"
, "WSAREA_ATTR", "HABSTRUCT", "UFC")
myDF[, col_missing] <- NA
df_met_val_bugs <- BioMonTools::metric.values(myDF
, "bugs"
, fun.cols2keep = myCols)
#> Joining with `by = join_by(SAMPLEID, INDEX_NAME, INDEX_CLASS)`
# Import Rules
df_rules <- readxl::read_excel(system.file("extdata/Rules.xlsx"
, package = "BCGcalc")
, sheet="Rules")
# Run function
df_met_memb <- BCG.Metric.Membership(df_met_val_bugs, df_rules)
# Show Results
#View(df_met_memb)
# Save Results
write.table(df_met_memb
, file.path(tempdir(), "Metric_Membership.tsv")
, row.names = FALSE
, col.names = TRUE
, sep = "\t")