Performs basic QC of a character column against a list of accepted values.
qc_taxa_values_character(
data,
col_vals = NULL,
valid_vals = NULL,
separator = NULL
)A data frame with col_vals values, occurrence (n), and if valid (TRUE/ FALSE). Any missing valid_vals are appended.
Returns a data frame of the values from the input with counts (column = n) from the column and whether the values appeared in valid values (column = valid). Values in the accepted values not appearing in the input are appended to the bottom of the returned data frame. These values are marked as n = NA and valid = TRUE. If NA is a valid value it must be included in valid_vals or in the output NA will be labeled as valid = FALSE.
The default accepted values for the abbreviations are those used in the function metric.values(). See below for examples.
Function Feeding Group (FFG) CF, CG, MH, OM, PA, PI, PR, SC, SH, XY User using FC and GC over CF and CG can modify the accepted values. Both versions are accepted in metric.values().
Habit BU, CB, CN, SK, SP, SW Values separated with "," are first split apart and spaces removed before checking. Not necessary to supply all possible combinations as each part is checked against the valid values.
Life Cycle (Voltinism) MULTI, SEMI, UNI
FFG2 DD, PRE
Thermal_Indicator STENOC, COLD, COOL, WARM, STENOW, EURYTHERMAL, COWA
HabStruct CS, NF, RM, SG
Habitat BRAC, DEPO, GENE, HEAD, LENT, LOTI, RHEA, RIVE, SPEC, TERR, UNKN
Elevation LOW, HIGH
Gradient LOW, MOD, HIGH
WSArea SMALL, MEDIUM, LARGE, XLARGE
BCG_ATTR 1, 2, 3, 4, 5, 6, 1I, 4_BETTER, 4_MIDDLE, 4_WORSE, 5.5, 6I, 6M, 6T,
# Values, FFG, Abr
qc_taxa_values_character(data_benthos_PacNW,
"FFG",
valid_vals = c("CF",
"CG",
"MH",
"OM",
"PA",
"PH",
"PI",
"PR",
"SC",
"SH",
"XY",
NA))
#> FFG n valid
#> 1 FC 51 FALSE
#> 2 GC 185 FALSE
#> 3 MH 6 TRUE
#> 4 OM 12 TRUE
#> 5 PR 145 TRUE
#> 6 SC 70 TRUE
#> 7 SH 61 TRUE
#> 8 <NA> 68 TRUE
# Values, FFG, full names
qc_taxa_values_character(data_benthos_MBSS,
"FFG",
valid_vals = c("Collector",
"Filterer",
"Predator",
"Scraper",
"Shredder"))
#> FFG n valid
#> 1 102 FALSE
#> 2 Collector 1843 TRUE
#> 3 Filterer 968 TRUE
#> 4 Predator 847 TRUE
#> 5 Scraper 611 TRUE
#> 6 Shredder 695 TRUE
# Values, Habit, no separator
qc_taxa_values_character(data_benthos_MBSS,
"Habit",
valid_vals = c("bu", "cb", "cn", "dv", "sk", "sp", "sw"))
#> Habit n valid
#> 1 406 FALSE
#> 2 - 20 FALSE
#> 3 bu 344 TRUE
#> 4 bu, cb, cn 2 FALSE
#> 5 bu, cn 3 FALSE
#> 6 bu, sp 60 FALSE
#> 7 cb 114 TRUE
#> 8 cb, cn 159 FALSE
#> 9 cb, cn, sp 3 FALSE
#> 10 cb, sp 74 FALSE
#> 11 cb, sp, cn 70 FALSE
#> 12 cb, sw 3 FALSE
#> 13 cn 1613 TRUE
#> 14 cn, bu 53 FALSE
#> 15 cn, cb 45 FALSE
#> 16 cn, cb, sp 19 FALSE
#> 17 cn, sp 100 FALSE
#> 18 cn, sp, cb 11 FALSE
#> 19 cn, sw 69 FALSE
#> 20 sk 2 TRUE
#> 21 sp 1168 TRUE
#> 22 sp, bu 265 FALSE
#> 23 sp, cb 3 FALSE
#> 24 sp, cb, cn 15 FALSE
#> 25 sp, cn 200 FALSE
#> 26 sp, sw 3 FALSE
#> 27 sw 5 TRUE
#> 28 sw, cb 57 FALSE
#> 29 sw, cb, cn 38 FALSE
#> 30 sw, cn 128 FALSE
#> 31 sw, cn, sp 6 FALSE
#> 32 sw, dv 8 FALSE
# Values, Habit, no separator
qc_taxa_values_character(data_benthos_MBSS,
"Habit",
valid_vals = c("bu", "cb", "cn", "dv", "sk", "sp", "sw"),
separator = ",")
#> Habit n valid
#> 1 406 FALSE
#> 2 - 20 FALSE
#> 3 bu 344 TRUE
#> 4 bu, cb, cn 2 FALSE
#> 5 bu, cn 3 FALSE
#> 6 bu, sp 60 FALSE
#> 7 cb 114 TRUE
#> 8 cb, cn 159 FALSE
#> 9 cb, cn, sp 3 FALSE
#> 10 cb, sp 74 FALSE
#> 11 cb, sp, cn 70 FALSE
#> 12 cb, sw 3 FALSE
#> 13 cn 1613 TRUE
#> 14 cn, bu 53 FALSE
#> 15 cn, cb 45 FALSE
#> 16 cn, cb, sp 19 FALSE
#> 17 cn, sp 100 FALSE
#> 18 cn, sp, cb 11 FALSE
#> 19 cn, sw 69 FALSE
#> 20 sk 2 TRUE
#> 21 sp 1168 TRUE
#> 22 sp, bu 265 FALSE
#> 23 sp, cb 3 FALSE
#> 24 sp, cb, cn 15 FALSE
#> 25 sp, cn 200 FALSE
#> 26 sp, sw 3 FALSE
#> 27 sw 5 TRUE
#> 28 sw, cb 57 FALSE
#> 29 sw, cb, cn 38 FALSE
#> 30 sw, cn 128 FALSE
#> 31 sw, cn, sp 6 FALSE
#> 32 sw, dv 8 FALSE