This function calculates metric values for bugs, fish, algae , and coral. Inputs are a data frame with SampleID and taxa with phylogenetic and autecological information (see below for required fields by community). The dplyr package is used to generate the metric values.
metric.values(
fun.DF,
fun.Community,
fun.MetricNames = NULL,
boo.Adjust = FALSE,
fun.cols2keep = NULL,
boo.marine = FALSE,
boo.Shiny = FALSE,
verbose = FALSE,
metric_subset = NULL,
taxaid_dni = NULL
)
Data frame of taxa (list required fields)
Community name for which to calculate metric values (bugs, fish, algae, or coral)
Optional vector of metric names to be returned. If none are supplied then all will be returned. Default=NULL
Optional boolean value on whether to perform adjustments of values prior to scoring. Default = FALSE but may be TRUE for certain metrics.
Column names of fun.DF to retain in the output. Uses column names.
Should estuary/marine metrics be included. Ignored if fun.MetricNames is not null. Default = FALSE.
Boolean value for if the function is accessed via Shiny. Default = FALSE.
Include messages to track progress. Default = FALSE
Subset of metrics to be generated. Internal function. Default = NULL
Taxa names to be included in DNI (Do Not Include) metrics (n = 3) but dropped for all other metrics. Only for benthic metrics. Default = NULL
data frame of SampleID and metric values
All percent metric results are 0-100.
No manipulations of the taxa are performed by this routine. All benthic macroinvertebrate taxa should be identified to the appropriate operational taxonomic unit (OTU).
Any non-count taxa should be identified in the "Exclude" field as "TRUE". These taxa will be excluded from taxa richness metrics (but will count for all others).
Any non-target taxa should be identified in the "NonTarget" field as "TRUE". Non-target taxa are those that are not part of your intended #' capture list; e.g., fish, herps, water column taxa, or water surface taxa in a benthic sample. The target list will vary by program. The non-target taxa will be removed prior to any calculations.
Excluded taxa are ambiguous taxa (on a sample basis), i.e., the parent taxa when child taxa are present. For example, the parent taxa Chironomidae would be excluded when the child taxa Tanytarsini is present. Both would be excluded when Tanytarsus is present. The markExcluded function can be used to populated this field.
There are a number of required fields (see below) for metric to calculation. If any fields are missing the user will be prompted as to which are missing and if the user wants to continue or quit. If the user continues the missing fields will be added but will be filled with zero or NA (as appropriate). Any metrics based on the missing fields will not be valid.
A future update may turn these fields into function parameters. This would allow the user to tweak the function inputs to match their data rather than having to update their data to match the function.
Required fields, all communities:
* SAMPLEID (character or number, must be unique)
* TAXAID (character or number, must be unique)
* N_TAXA
* INDEX_NAME
* INDEX_CLASS (BCG or MMI site category; e.g., for BCG PacNW valid values are "hi" or "lo")
Additional Required fields, bugs:
* EXCLUDE (valid values are TRUE and FALSE)
* NONTARGET (valid values are TRUE and FALSE)
* PHYLUM, SUBPHYLUM, CLASS, SUBCLASS, INFRAORDER, ORDER, FAMILY, SUBFAMILY, TRIBE, GENUS
* FFG, HABIT, LIFE_CYCLE, TOLVAL, BCG_ATTR, THERMAL_INDICATOR, FFG2, TOLVAL2, LONGLIVED, NOTEWORTHY, HABITAT, UFC, ELEVATION_ATTR, GRADIENT_ATTR, WSAREA_ATTR, HABSTRUCT
Additional Required fields, fish:
* N_ANOMALIES
* SAMP_BIOMASS (biomass total for sample, funciton uses max in case entered for all taxa in sample)
* DA_MI2, SAMP_WIDTH_M, SAMP_LENGTH_M, , TYPE, TOLER, NATIVE, TROPHIC, SILT, FAMILY, GENUS, HYBRID, BCG_ATTR, THERMAL_INDICATOR, ELEVATION_ATTR, GRADIENT_ATTR, WSAREA_ATTR, REPRODUCTION, HABITAT, CONNECTIVITY, SCC
Additional Required fields, algae:
* EXCLUDE, NONTARGET, PHYLUM, ORDER, FAMILY, GENUS, BC_USGS, TROPHIC_USGS, SAP_USGS, PT_USGS, O_USGS, SALINITY_USGS, BAHLS_USGS, P_USGS, N_USGS, HABITAT_USGS, N_FIXER_USGS, MOTILITY_USGS, SIZE_USGS, HABIT_USGS, MOTILE2_USGS, TOLVAL, DIATOM_ISA, DIAT_CL, POLL_TOL, BEN_SES, DIATAS_TP, DIATAS_TN, DIAT_COND, DIAT_CA, MOTILITY, NF
Valid values for fields:
* FFG: CG, CF, PR, SC, SH
* HABIT: BU, CB, CN, SP, SW
* LIFE_CYCLE: UNI, SEMI, MULTI
* THERMAL_INDICATOR: STENOC, COLD, COOL, WARM, STENOW, EURYTHERMAL , COWA, NA
* LONGLIVED: TRUE, FALSE
* NOTEWORTHY: TRUE, FALSE
* HABITAT: BRAC, DEPO, GENE, HEAD, RHEO, RIVE, SPEC, UNKN
* UFC: integers 1:6 (taxonomic uncertainty frequency class)
* ELEVATION_ATTR: LOW, HIGH
* GRADIENT_ATTR: LOW, MOD, HIGH
* WSAREA_ATTR: SMALL, MEDIUM, LARGE, XLARGE
* REPRODUCTION: BROADCASTER, SIMPLE NEST, COMPLEX NEST, BEARER, MIGRATORY
* CONNECTIVITY: TRUE, FALSE
* SCC (Species of Conservation Concern): TRUE, FALSE
'Columns to keep' are additional fields in the input file that the user wants retained in the output. Fields need to be those that are unique per sample and not associated with the taxa. For example, the fields used in qc.check(); Area_mi2, SurfaceArea, Density_m2, and Density_ft2.
If fun.MetricNames is provided only those metrics will be returned in the provided order. This variable can be used to sort the metrics per the user's preferences. By default the metric names will be returned in the groupings that were used for calculation.
The fields TOLVAL2 and FFG2 are provided to allow the user to calculate metrics based on alternative scenarios. For example, including both HBI and NCBI where the NCBI uses a different set of tolerance values (TOLVAL2).
If TAXAID is 'NONE' and N_TAXA is '0' then metrics **will** be calculated with that record. Other values for TAXAID with N_TAXA = 0 will be removed before calculations.
For 'Oligochete' metrics either Class or Subclass is required for calculation.
The parameter boo.Shiny can be set to TRUE when accessing this function in Shiny. Normally the QC check for required fields is interactive. Setting boo.Shiny to TRUE will always continue. The default is FALSE.
The parameter 'taxaid_dni' denotes taxa to be included in Do Not Include (DNI) metrics but dropped from all other metrics. Only for benthic metrics.
Breaking change from 0.5 to 0.6 with change from Index_Name to Index_Class.
# Example 1, data already in R
df_metric_values_bugs <- metric.values(data_benthos_PacNW, "bugs")
#> Joining with `by = join_by(SAMPLEID, INDEX_NAME, INDEX_CLASS)`
if (FALSE) {
# View Results
View(df_metric_values_bugs)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Example 2, data from Excel
if (FALSE) {
# Packages
library(readxl)
library(reshape2)
df_samps_bugs <- read_excel(system.file("extdata/Data_Benthos.xlsx"
, package = "BioMonTools")
, guess_max = 10^6)
# Columns to keep
myCols <- c("Area_mi2", "SurfaceArea", "Density_m2", "Density_ft2")
# Run Function
df_metric_values_bugs <- metric.values(df_samps_bugs[1:100, ]
, "bugs"
, fun.cols2keep = myCols)
# View Results
View(df_metric_values_bugs)
}
# Get data in long format so can QC results more easily
df_long <- melt(df_metric_values_bugs, id.vars = c("SAMPLEID"
, "INDEX_NAME"
, "INDEX_CLASS"
, toupper(myCols))
, variable.name = "METRIC_NAME"
, value.name = "METRIC_VALUE")
#> Error in eval(expr, envir, enclos): object 'myCols' not found
if (FALSE) {
# Save Results
write.table(df_long, file.path(tempdir(), "metric.values.tsv")
, col.names = TRUE, row.names = FALSE, sep = "\t")
# DataExplorer Report
library(DataExplorer)
create_report(df_metric_values_bugs
, output_file = file.path(tempdir()
, "DataExplorer_Report_MetricValues.html"))
create_report(df_samps_bugs
, output_file = file.path(tempdir()
, "DataExplorer_Report_BugSamples.html"))
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Example 3, specific metrics or metrics in a specific order
## reuse df_samps_bugs from above
# metric names to keep (in this order)
myMetrics <- c("ni_total", "nt_EPT", "nt_Ephem", "pi_tv_intol", "pi_Ephem"
, "nt_ffg_scrap", "pi_habit_climb")
# Run Function
df_metric_values_bugs_myMetrics <- metric.values(df_samps_bugs, "bugs"
, fun.MetricNames = myMetrics)
#> Error in eval(expr, envir, enclos): object 'df_samps_bugs' not found
if (FALSE) {
# View Results
View(df_metric_values_bugs_myMetrics)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Example 4, fish metrics
df_metric_values_fish <- metric.values(data_fish_MBSS, "fish")
#>
#> There are 1 missing fields in the data:
#> BCG_ATTR2
#>
#> If you continue the metrics associated with these fields will be invalid.
#> For example, if the NATIVE field is missing all native related metrics will not be correct.
#> Do you wish to continue (YES or NO)?
#> boo.Shiny == TRUE and interactive == FALSE
#> so prompt skipped and value set to '1'.
#> Warning: Metrics related to the following fields are invalid:
#> BCG_ATTR2
#> EXCLUDE column does not have any TRUE values.
#> This is common with fish samples.
#> Valid values are TRUE or FALSE.
#> Other values are not recognized
#> Error in dplyr::summarise(dplyr::group_by(myDF, SAMPLEID, INDEX_NAME, INDEX_CLASS, SAMP_WIDTH_M, SAMP_LENGTH_M), .groups = "drop_last", ni_total = sum(N_TAXA, na.rm = TRUE), ni_total_notoler = sum(N_TAXA[TOLER != "TOLERANT" | is.na(TOLER)], na.rm = TRUE), ni_natnonhybridnonmf = sum(N_TAXA[NATIVE == "NATIVE" & (HYBRID != TRUE | is.na(HYBRID)) & (TYPE != "MOSQUITOFISH" | is.na(TYPE))], na.rm = TRUE), ni_natnonhybridnonmfnonLepomis = sum(N_TAXA[NATIVE == "NATIVE" & (HYBRID != TRUE | is.na(HYBRID)) & (TYPE != "MOSQUITOFISH" | is.na(TYPE)) & (GENUS != "LEPOMIS" | is.na(GENUS))], na.rm = TRUE), pi_AmmEthPerc = 100 * sum(N_TAXA[GENUS == "AMMOCRYPTA" | GENUS == "ETHEOSTOMA" | GENUS == "PERCINA"], na.rm = TRUE)/ni_total, pi_AmmEthPerc_Cott_Notur = 100 * sum(N_TAXA[(GENUS == "AMMOCRYPTA" | GENUS == "ETHEOSTOMA" | GENUS == "PERCINA" | GENUS == "NOTURUS") | FAMILY == "COTTIDAE"], na.rm = TRUE)/ni_total, pi_rbs = 100 * sum(N_TAXA[TYPE == "RBS"], na.rm = TRUE)/ni_total, pi_brooktrout = 100 * sum(N_TAXA[TYPE == "BROOK TROUT"], na.rm = TRUE)/ni_total, pi_brooktrout_wild = 100 * sum(N_TAXA[TAXAID == "BROOK TROUT, WILD"], na.rm = TRUE)/ni_total, pi_Cato = 100 * sum(N_TAXA[FAMILY == "CATOSTOMIDAE"], na.rm = TRUE)/ni_total, pi_Cent = 100 * sum(N_TAXA[FAMILY == "CENTRARCHIDAE"], na.rm = TRUE)/ni_total, pi_natCent = 100 * sum(N_TAXA[NATIVE == "NATIVE" & FAMILY == "CENTRARCHIDAE"], na.rm = TRUE)/ni_total, pi_Cott = 100 * sum(N_TAXA[FAMILY == "COTTIDAE"], na.rm = TRUE)/ni_total, pi_Cyprin = 100 * sum(N_TAXA[FAMILY == "CYPRINIDAE"], na.rm = TRUE)/ni_total, pi_Ictal = 100 * sum(N_TAXA[FAMILY == "ICTALURIDAE"], na.rm = TRUE)/ni_total, pi_native = 100 * sum(N_TAXA[NATIVE == "NATIVE"], na.rm = TRUE)/ni_total, pi_nonnative = 100 * sum(N_TAXA[is.na(NATIVE) | NATIVE != "NATIVE"], na.rm = TRUE)/ni_total, pi_Notur = 100 * sum(N_TAXA[GENUS == "NOTURUS"], na.rm = TRUE)/ni_total, pi_sculpin = 100 * sum(N_TAXA[TYPE == "SCULPIN"], na.rm = TRUE)/ni_total, pi_Lepomis = 100 * sum(N_TAXA[GENUS == "LEPOMIS"], na.rm = TRUE)/ni_total, pi_Salm = 100 * sum(N_TAXA[FAMILY == "SALMONIDAE"], na.rm = TRUE)/ni_total, pi_trout = 100 * sum(N_TAXA["TROUT" %in% TYPE], na.rm = TRUE)/ni_total, pi_brooktrout_BCG_att6 = 100 * (sum(N_TAXA[TYPE == "BROOK TROUT"], na.rm = TRUE) + sum(N_TAXA[BCG_ATTR == "6"], na.rm = TRUE))/ni_total, pi_connect = 100 * sum(N_TAXA[CONNECTIVITY == TRUE], na.rm = TRUE)/ni_total, pi_scc = 100 * sum(N_TAXA[SCC == TRUE], na.rm = TRUE)/ni_total, pi_brooktrout2brooktrout_BCG_att6 = 100 * sum(N_TAXA[TYPE == "BROOK TROUT"], na.rm = TRUE)/(sum(N_TAXA[TYPE == "BROOK TROUT"], na.rm = TRUE) + sum(N_TAXA[BCG_ATTR == "6"], na.rm = TRUE)), pi_bfs = 100 * sum(N_TAXA[(TYPE == "BENTHIC" & TROPHIC_IV == TRUE) | TYPE == "RBS" | TYPE == "SMM"], na.rm = TRUE)/ni_total, nt_total = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & N_TAXA > 0], na.rm = TRUE), nt_benthic = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE == "BENTHIC"], na.rm = TRUE), nt_AmmEthPerc = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (GENUS == "AMMOCRYPTA" | GENUS == "ETHEOSTOMA" | GENUS == "PERCINA")], na.rm = TRUE), nt_AmmEthPerc_Cott_Notur = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (GENUS == "AMMOCRYPTA" | GENUS == "ETHEOSTOMA" | GENUS == "PERCINA" | GENUS == "NOTURUS") | FAMILY == "COTTIDAE"], na.rm = TRUE), nt_Cato = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "CATOSTOMIDAE"], na.rm = TRUE), nt_Cent = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "CENTRARCHIDAE"], na.rm = TRUE), nt_natCent = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & FAMILY == "CENTRARCHIDAE"], na.rm = TRUE), nt_Cott = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "COTTIDAE"], na.rm = TRUE), nt_Cyprin = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "CYPRINIDAE"], na.rm = TRUE), nt_natCyprin = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & FAMILY == "CYPRINIDAE"], na.rm = TRUE), nt_Lepomis = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & GENUS == "LEPOMIS"], na.rm = TRUE), nt_native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & N_TAXA > 0], na.rm = TRUE), nt_nonnative = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (is.na(NATIVE) | NATIVE != "NATIVE") & N_TAXA > 0], na.rm = TRUE), nt_nativenonhybrid = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & (HYBRID != TRUE | is.na(HYBRID))], na.rm = TRUE), nt_Notur = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & GENUS == "NOTURUS"], na.rm = TRUE), nt_Ictal = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "ICTALURIDAE"], na.rm = TRUE), nt_natsunfish = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & TYPE == "SUNFISH"], na.rm = TRUE), nt_natCent_sunfish = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & (TYPE == "SUNFISH" | TYPE == "CENTRARCHIDAE")], na.rm = TRUE), nt_natCent = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & FAMILY == "CENTRARCHIDAE"], na.rm = TRUE), nt_natinsctCypr = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & TROPHIC_IS == TRUE & FAMILY == "CYPRINIDAE"], na.rm = TRUE), nt_natrbs = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & TYPE == "RBS"], na.rm = TRUE), nt_Petro = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "PETROMYZONTIDAE"], na.rm = TRUE), nt_Salm = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "SALMONIDAE"], na.rm = TRUE), nt_connect = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & CONNECTIVITY == TRUE], na.rm = TRUE), nt_scc = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & SCC == TRUE], na.rm = TRUE), nt_beninsct_nows_nobg = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_IS == TRUE & (TAXAID != "CATOSTOMUS COMMERSONII" | TAXAID != "LEPOMIS MACROCHIRUS" | is.na(TAXAID))], na.rm = TRUE), nt_trout_sunfish_notoler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & ("TROUT" %in% TYPE | TYPE == "SUNFISH") & (TOLER != "TOLERANT" | is.na(TOLER))], na.rm = TRUE), pt_AmmEthPerc = 100 * nt_AmmEthPerc/nt_total, pt_AmmEthPerc_Cott_Notur = 100 * nt_AmmEthPerc_Cott_Notur/nt_total, pt_Cato = 100 * nt_Cato/nt_total, pt_Cent = 100 * nt_Cent/nt_total, pt_natCent = 100 * nt_natCent/nt_total, pt_Cott = 100 * nt_Cott/nt_total, pt_Cyprin = 100 * nt_Cyprin/nt_total, pt_Ictal = 100 * nt_Ictal/nt_total, pt_Lepomis = 100 * nt_Lepomis/nt_total, pt_native = 100 * nt_native/nt_total, pt_nonnative = 100 * nt_nonnative/nt_total, pt_Notur = 100 * nt_Notur/nt_total, pt_Salm = 100 * nt_Salm/nt_total, pt_connect = 100 * nt_connect/nt_total, pt_scc = 100 * nt_scc/nt_total, nt_beninvert = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE == "BENTHIC" & TROPHIC_IV == TRUE], na.rm = TRUE), nt_habitat_beninvert = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_IV == TRUE & HABITAT_B == TRUE], na.rm = TRUE), nt_detritivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_DE == TRUE], na.rm = TRUE), nt_herbivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_HB == TRUE], na.rm = TRUE), nt_omnivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_OM == TRUE], na.rm = TRUE), nt_planktivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_PL == TRUE], na.rm = TRUE), nt_topcarn = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_TC == TRUE], na.rm = TRUE), nt_piscivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_PI == TRUE], na.rm = TRUE), pi_lithophil = 100 * sum(N_TAXA[SILT == TRUE], na.rm = TRUE)/ni_total, pi_habitat_beninvert = 100 * sum(N_TAXA[TROPHIC_IV == TRUE & HABITAT_B == TRUE], na.rm = TRUE)/ni_total, pi_detritivore = 100 * sum(N_TAXA[TROPHIC_DE == TRUE], na.rm = TRUE)/ni_total, pi_genomninvrt = 100 * sum(N_TAXA[TROPHIC_GE == TRUE | TROPHIC_OM == TRUE | TROPHIC_IV == TRUE], na.rm = TRUE)/ni_total, pi_herbivore = 100 * sum(N_TAXA[TROPHIC_HB == TRUE], na.rm = TRUE)/ni_total, pi_insectivore = 100 * sum(N_TAXA[TROPHIC_IS == TRUE], na.rm = TRUE)/ni_total, pi_insctCypr = 100 * sum(N_TAXA[TROPHIC_IS == TRUE & FAMILY == "CYPRINIDAE"], na.rm = TRUE)/ni_total, pi_gen = 100 * sum(N_TAXA[TROPHIC_GE == TRUE], na.rm = TRUE)/ni_total, pi_genherb = 100 * sum(N_TAXA[TROPHIC_GE == TRUE | TROPHIC_HB == TRUE], na.rm = TRUE)/ni_total, pi_omnivore = 100 * sum(N_TAXA[TROPHIC_OM == TRUE], na.rm = TRUE)/ni_total, pi_planktivore = 100 * sum(N_TAXA[TROPHIC_PL == TRUE], na.rm = TRUE)/ni_total, pi_topcarn = 100 * sum(N_TAXA[TROPHIC_TC == TRUE], na.rm = TRUE)/ni_total, pi_trout = 100 * sum(N_TAXA["TROUT" %in% TYPE], na.rm = TRUE)/ni_total, pi_pisc_noae = 100 * sum(N_TAXA[TYPE == "PISCIVORE" & (TAXAID != "ANGUILLA ROSTRATA" | is.na(TAXAID))], na.rm = TRUE)/ni_total, pt_habitat_beninvert = 100 * nt_habitat_beninvert/nt_total, pt_detritivore = 100 * nt_detritivore/nt_total, pt_herbivore = 100 * nt_herbivore/nt_total, pt_omnivore = 100 * nt_omnivore/nt_total, pt_planktivore = 100 * nt_planktivore/nt_total, pt_topcarn = 100 * nt_topcarn/nt_total, nt_tv_intol = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER == "INTOLERANT"], na.rm = TRUE), nt_tv_intolhwi = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (TOLER == "INTOLERANT" | TOLER == "HWI")], na.rm = TRUE), pi_tv_toler = 100 * sum(N_TAXA[TOLER == "TOLERANT"], na.rm = TRUE)/ni_total, x_Shan_e = -sum((N_TAXA/ni_total) * log((N_TAXA/ni_total)), na.rm = TRUE), x_Shan_2 = x_Shan_e/log(2), x_Shan_10 = x_Shan_e/log(10), x_Evenness = x_Shan_e/log(nt_total), x_Evenness100_ni99gt = ifelse(ni_total < 100, 1, x_Evenness * 100), length_m = max(SAMP_LENGTH_M, na.rm = TRUE), area_m2 = max(SAMP_WIDTH_M, na.rm = TRUE) * length_m, ni_m2 = ni_total/area_m2, ni_200m = 200 * ni_total/length_m, ni_natnonhybridnonmf_200m = 200 * ni_natnonhybridnonmf/length_m, ni_natnonhybridnonmfnonLepomis_200m = 200 * ni_natnonhybridnonmfnonLepomis/length_m, biomass_m2 = max(SAMP_BIOMASS, na.rm = TRUE)/area_m2, pi_anomalies = 100 * sum(N_ANOMALIES, na.rm = TRUE)/ni_total, pi_delt = 100 * sum(N_ANOMALIES, na.rm = TRUE)/ni_total, pi_dom01 = 100 * max(N_TAXA, na.rm = TRUE)/ni_total, pi_dom02 = 100 * max(ni_dom02, na.rm = TRUE)/ni_total, pi_dom03 = 100 * max(ni_dom03, na.rm = TRUE)/ni_total, pi_dom04 = 100 * max(ni_dom04, na.rm = TRUE)/ni_total, pi_dom05 = 100 * max(ni_dom05, na.rm = TRUE)/ni_total, pi_dom06 = 100 * max(ni_dom06, na.rm = TRUE)/ni_total, pi_dom07 = 100 * max(ni_dom07, na.rm = TRUE)/ni_total, pi_dom08 = 100 * max(ni_dom08, na.rm = TRUE)/ni_total, pi_dom09 = 100 * max(ni_dom09, na.rm = TRUE)/ni_total, pi_dom10 = 100 * max(ni_dom10, na.rm = TRUE)/ni_total, nt_BCG_att1 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "1"], na.rm = TRUE), nt_BCG_att12 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2")], na.rm = TRUE), nt_BCG_att123 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3")], na.rm = TRUE), nt_BCG2_att123b = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR2 == "3_BETTER")], na.rm = TRUE), nt_BCG_att1234 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4")], na.rm = TRUE), nt_BCG2_att1234b = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR2 == "4_BETTER")], na.rm = TRUE), nt_BCG_att1236 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6")], na.rm = TRUE), nt_BCG_att1236b = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6B")], na.rm = TRUE), nt_BCG_att12346 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4" | BCG_ATTR == "6")], na.rm = TRUE), nt_BCG_att12346b = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4" | BCG_ATTR == "6B")], na.rm = TRUE), nt_BCG_att1i236i = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "1I" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6I")], na.rm = TRUE), nt_BCG_att2 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "2"], na.rm = TRUE), nt_BCG_att2native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "2" & NATIVE == "NATIVE"], na.rm = TRUE), nt_BCG_att23_scc = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "2" | BCG_ATTR == "3") & SCC == TRUE], na.rm = TRUE), nt_BCG_att3 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "3"], na.rm = TRUE), nt_BCG_att3native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "3" & NATIVE == "NATIVE"], na.rm = TRUE), nt_BCG_att4 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "4"], na.rm = TRUE), nt_BCG_att4native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "4" & NATIVE == "NATIVE"], na.rm = TRUE), nt_BCG_att5 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "5"], na.rm = TRUE), nt_BCG_att5native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "5" & NATIVE == "NATIVE"], na.rm = TRUE), nt_BCG_att55a6 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "5" | BCG_ATTR == "5A" | BCG_ATTR == "6")], na.rm = TRUE), nt_BCG_att55a6a = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "5" | BCG_ATTR == "5A" | BCG_ATTR == "6A")], na.rm = TRUE), nt_BCG_att56t = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (BCG_ATTR == "5" | BCG_ATTR == "6T")], na.rm = TRUE), nt_BCG_att6i = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "6I"], na.rm = TRUE), nt_BCG_att6m = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "6M"], na.rm = TRUE), nt_BCG_att6t = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & BCG_ATTR == "6T"], na.rm = TRUE), nt_BCG_attNA = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & is.na(BCG_ATTR)], na.rm = TRUE), pi_BCG_att12 = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2")], na.rm = TRUE)/ni_total, pi_BCG_att123 = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3")], na.rm = TRUE)/ni_total, pi_BCG_att1234 = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4")], na.rm = TRUE)/ni_total, pi_BCG_att1236 = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6")], na.rm = TRUE)/ni_total, pi_BCG_att1236sp = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6")], na.rm = TRUE)/sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6" | BCG_ATTR == "5" | BCG_ATTR == "5A" | BCG_ATTR == "6A")], na.rm = TRUE), pi_BCG_att1236b = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6B")], na.rm = TRUE)/ni_total, pi_BCG_att12346b = 100 * sum(N_TAXA[(BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4" | BCG_ATTR == "6B")], na.rm = TRUE)/ni_total, pi_BCG_att1i236i = 100 * sum(N_TAXA[(BCG_ATTR == "1I" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "6I")], na.rm = TRUE)/ni_total, pi_BCG_att2 = 100 * sum(N_TAXA[BCG_ATTR == "2"], na.rm = TRUE)/ni_total, pi_BCG_att2native = 100 * sum(N_TAXA[BCG_ATTR == "2" & NATIVE == "NATIVE"], na.rm = TRUE)/ni_total, pi_BCG_att23_scc = 100 * sum(N_TAXA[(BCG_ATTR == "2" | BCG_ATTR == "3") & SCC == TRUE], na.rm = TRUE)/ni_total, pi_BCG_att3 = 100 * sum(N_TAXA[BCG_ATTR == "3"], na.rm = TRUE)/ni_total, pi_BCG_att3native = 100 * sum(N_TAXA[BCG_ATTR == "3" & NATIVE == "NATIVE"], na.rm = TRUE)/ni_total, pi_BCG_att4 = 100 * sum(N_TAXA[BCG_ATTR == "4"], na.rm = TRUE)/ni_total, pi_BCG_att4native = 100 * sum(N_TAXA[BCG_ATTR == "4" & NATIVE == "NATIVE"], na.rm = TRUE)/ni_total, pi_BCG_att5 = 100 * sum(N_TAXA[BCG_ATTR == "5"], na.rm = TRUE)/ni_total, pi_BCG_att5native = 100 * sum(N_TAXA[BCG_ATTR == "5" & NATIVE == "NATIVE"], na.rm = TRUE)/ni_total, pi_BCG_att55a6a = 100 * sum(N_TAXA[(BCG_ATTR == "5" | BCG_ATTR == "5A" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, pi_BCG_att56a = 100 * sum(N_TAXA[(BCG_ATTR == "5" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, pi_BCG_att5a6a = 100 * sum(N_TAXA[(BCG_ATTR == "5A" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, pi_BCG_att56t = 100 * sum(N_TAXA[(BCG_ATTR == "5" | BCG_ATTR == "6T")], na.rm = TRUE)/ni_total, pi_BCG_att6 = 100 * sum(N_TAXA[BCG_ATTR == "6"], na.rm = TRUE)/ni_total, pi_BCG_att6i = 100 * sum(N_TAXA[BCG_ATTR == "6I"], na.rm = TRUE)/ni_total, pi_BCG_att6m = 100 * sum(N_TAXA[BCG_ATTR == "6M"], na.rm = TRUE)/ni_total, pi_BCG_att6t = 100 * sum(N_TAXA[BCG_ATTR == "6T"], na.rm = TRUE)/ni_total, pi_BCG_att66a = 100 * sum(N_TAXA[(BCG_ATTR == "6" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, pi_BCG_att66a6b = 100 * sum(N_TAXA[(BCG_ATTR == "6" | BCG_ATTR == "6A" | BCG_ATTR == "6B")], na.rm = TRUE)/ni_total, pi_BCG_att66s6t = 100 * sum(N_TAXA[BCG_ATTR == "6" | BCG_ATTR == "6S" | BCG_ATTR == "6T"], na.rm = TRUE)/ni_total, pi_BCG_attNA = 100 * sum(N_TAXA[is.na(BCG_ATTR)], na.rm = TRUE)/ni_total, pt_BCG_att12 = 100 * nt_BCG_att12/nt_total, pt_BCG_att123 = 100 * nt_BCG_att123/nt_total, pt_BCG2_att123b = 100 * nt_BCG2_att123b/nt_total, pt_BCG_att1234 = 100 * nt_BCG_att1234/nt_total, pt_BCG2_att1234b = 100 * nt_BCG2_att1234b/nt_total, pt_BCG_att1236 = 100 * nt_BCG_att1236/nt_total, pt_BCG_att1236b = 100 * nt_BCG_att1236b/nt_total, pt_BCG_att1236sp = 100 * nt_BCG_att1236/(nt_BCG_att1236 + nt_BCG_att55a6a), pt_BCG_att12346b = 100 * nt_BCG_att12346b/nt_total, pt_BCG_att1i236i = 100 * nt_BCG_att1i236i/nt_total, pt_BCG_att2 = 100 * nt_BCG_att2/nt_total, pt_BCG_att2native = 100 * nt_BCG_att2native/nt_total, pt_BCG_att23_scc = 100 * nt_BCG_att23_scc/nt_total, pt_BCG_att3 = 100 * nt_BCG_att3/nt_total, pt_BCG_att3native = 100 * nt_BCG_att3native/nt_total, pt_BCG_att4 = 100 * nt_BCG_att4/nt_total, pt_BCG_att4native = 100 * nt_BCG_att4native/nt_total, pt_BCG_att5 = 100 * nt_BCG_att5/nt_total, pt_BCG_att5native = 100 * nt_BCG_att5native/nt_total, pt_BCG_att55a6a = 100 * nt_BCG_att55a6/nt_total, pt_BCG_att56t = 100 * nt_BCG_att56t/nt_total, pt_BCG_att6i = 100 * nt_BCG_att6i/nt_total, pt_BCG_att6m = 100 * nt_BCG_att6m/nt_total, pt_BCG_att6t = 100 * nt_BCG_att6t/nt_total, pt_BCG_attNA = 100 * nt_BCG_attNA/nt_total, pi_dom01_BCG_att4 = 100 * max(0, N_TAXA[(BCG_ATTR == "4")], na.rm = TRUE)/ni_total, pi_dom01_BCG_att45 = 100 * max(0, N_TAXA[(BCG_ATTR == "4" | BCG_ATTR == "5")], na.rm = TRUE)/ni_total, pi_dom01_BCG_att5 = 100 * max(0, N_TAXA[(BCG_ATTR == "5")], na.rm = TRUE)/ni_total, pi_dom01_BCG_att5a = 100 * max(0, N_TAXA[(BCG_ATTR == "5A")], na.rm = TRUE)/ni_total, pi_dom01_BCG_att5a6a = 100 * max(0, N_TAXA[(BCG_ATTR == "5A" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, pi_dom01_BCG_att566a = 100 * max(0, N_TAXA[(BCG_ATTR == "5" | BCG_ATTR == "6" | BCG_ATTR == "6A")], na.rm = TRUE)/ni_total, nt_ti_corecold = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_CORECOLD == TRUE], na.rm = TRUE), nt_ti_cold = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_COLD == TRUE], na.rm = TRUE), nt_ti_cool = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_COOL == TRUE], na.rm = TRUE), nt_ti_warm = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_WARM == TRUE], na.rm = TRUE), nt_ti_eury = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_EURY == TRUE], na.rm = TRUE), nt_ti_na = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TI_NA == TRUE], na.rm = TRUE), nt_ti_corecold_cold = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (TI_CORECOLD == TRUE | TI_COLD == TRUE)], na.rm = TRUE), nt_ti_cool_warm = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (TI_COOL == TRUE | TI_WARM == TRUE)], na.rm = TRUE), pi_ti_corecold = 100 * sum(N_TAXA[TI_CORECOLD == TRUE], na.rm = TRUE)/ni_total, pi_ti_cold = 100 * sum(N_TAXA[TI_COLD == TRUE], na.rm = TRUE)/ni_total, pi_ti_cool = 100 * sum(N_TAXA[TI_COOL == TRUE], na.rm = TRUE)/ni_total, pi_ti_warm = 100 * sum(N_TAXA[TI_WARM == TRUE], na.rm = TRUE)/ni_total, pi_ti_eury = 100 * sum(N_TAXA[TI_EURY == TRUE], na.rm = TRUE)/ni_total, pi_ti_na = 100 * sum(N_TAXA[TI_NA == TRUE], na.rm = TRUE)/ni_total, pi_ti_corecold_cold = 100 * sum(N_TAXA[TI_CORECOLD == TRUE | TI_COLD == TRUE], na.rm = TRUE)/ni_total, pi_ti_cool_warm = 100 * sum(N_TAXA[TI_COOL == TRUE | TI_WARM == TRUE], na.rm = TRUE)/ni_total, pt_ti_corecold = 100 * nt_ti_corecold/nt_total, pt_ti_cold = 100 * nt_ti_cold/nt_total, pt_ti_cool = 100 * nt_ti_cool/nt_total, pt_ti_warm = 100 * nt_ti_warm/nt_total, pt_ti_eury = 100 * nt_ti_eury/nt_total, pt_ti_na = 100 * nt_ti_na/nt_total, pt_ti_corecold_cold = 100 * nt_ti_corecold_cold/nt_total, pt_ti_cool_warm = 100 * nt_ti_cool_warm/nt_total, nt_elev_low = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & ELEVATION_LOW == TRUE], na.rm = TRUE), nt_elev_high = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & ELEVATION_HIGH == TRUE], na.rm = TRUE), nt_grad_low = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & GRADIENT_LOW == TRUE], na.rm = TRUE), nt_grad_mod = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & GRADIENT_MOD == TRUE], na.rm = TRUE), nt_grad_high = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & GRADIENT_HIGH == TRUE], na.rm = TRUE), nt_wsarea_small = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & WSAREA_S == TRUE], na.rm = TRUE), nt_wsarea_medium = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & WSAREA_M == TRUE], na.rm = TRUE), nt_wsarea_large = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & WSAREA_L == TRUE], na.rm = TRUE), nt_wsarea_xlarge = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & WSAREA_XL == TRUE], na.rm = TRUE), nt_repro_broadcaster = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_BCAST == TRUE], na.rm = TRUE), nt_repro_nestsimp = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_NS == TRUE], na.rm = TRUE), nt_repro_nestcomp = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_NC == TRUE], na.rm = TRUE), nt_repro_bearer = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_BEAR == TRUE], na.rm = TRUE), nt_repro_migratory = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_MIG == TRUE], na.rm = TRUE), nt_repro_lithophil = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_LITH == TRUE], na.rm = TRUE), pi_repro_lithophil = 100 * sum(N_TAXA[REPRO_LITH == TRUE], na.rm = TRUE)/ni_total, pt_repro_lithophil = 100 * nt_repro_lithophil/nt_total, nt_habitat_b = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_B == TRUE], na.rm = TRUE), nt_habitat_w = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_W == TRUE], na.rm = TRUE), nt_habitat_f = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_F == TRUE], na.rm = TRUE), pi_habitat_b = 100 * sum(N_TAXA[HABITAT_B == TRUE], na.rm = TRUE)/ni_total, pi_habitat_w = 100 * sum(N_TAXA[HABITAT_W == TRUE], na.rm = TRUE)/ni_total, pi_habitat_f = 100 * sum(N_TAXA[HABITAT_F == TRUE], na.rm = TRUE)/ni_total, pt_habitat_b = 100 * nt_habitat_b/nt_total, pt_habitat_w = 100 * nt_habitat_w/nt_total, pt_habitat_f = 100 * nt_habitat_f/nt_total, nt_piscivore_BCG_att66s6t = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_PI == TRUE & (BCG_ATTR == "6" | BCG_ATTR == "6S" | BCG_ATTR == "6T")], na.rm = TRUE), nt_LLNLB = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE == "LLNLB"], na.rm = TRUE), nt_Cyprin_BCG_att1234 = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "CYPRINIDAE" & (BCG_ATTR == "1" | BCG_ATTR == "2" | BCG_ATTR == "3" | BCG_ATTR == "4")], na.rm = TRUE), ni_Hybognathus_amarus = sum(N_TAXA[TAXAID == "HYBOGNATHUS AMARUS"], na.rm = TRUE), x_TrophicCats = dplyr::n_distinct(TROPHIC, na.rm = TRUE), x_BCG_Mean = mean(TOLVAL2, na.rm = TRUE), nt_PupKilli = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (TAXAID == "CYPRINODON RUBROFLUVIATILIS" | TAXAID == "FUNDULUS KANSAE" | TAXAID == "FUNDULUS ZEBRINUS")], na.rm = TRUE), ni_total_ExclSchool = sum(N_TAXA[TYPE_SCHOOL != TRUE], na.rm = TRUE), ni_total_notoler_mn = sum(N_TAXA[TOLER_T != TRUE], na.rm = TRUE), nt_coldwater = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_CW == TRUE], na.rm = TRUE), nt_natcoldwater = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_CWN == TRUE], na.rm = TRUE), nt_hw_notoler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & HABITAT_HW_noT == TRUE], na.rm = TRUE), nt_serialspawner = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_SER == TRUE], na.rm = TRUE), nt_simplelithophil = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & REPRO_SILI == TRUE], na.rm = TRUE), nt_tv_sens = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER_S == TRUE], na.rm = TRUE), nt_tv_senscoldwater = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER_SCW == TRUE], na.rm = TRUE), nt_tv_tolercoldwater = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER_TCW == TRUE], na.rm = TRUE), nt_tv_toler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER_T == TRUE], na.rm = TRUE), nt_tv_vtoler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER_VT == TRUE], na.rm = TRUE), nt_beninsct_notoler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_BI_noT == TRUE], na.rm = TRUE), nt_detritivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_DE == TRUE], na.rm = TRUE), nt_gen = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_GE == TRUE], na.rm = TRUE), nt_insectivore_notoler = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_IN_noT == TRUE], na.rm = TRUE), nt_omnivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TROPHIC_OM == TRUE], na.rm = TRUE), nt_dartersculpin = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE_DS == TRUE], na.rm = TRUE), nt_darterscultpinsucker = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE_DSS == TRUE], na.rm = TRUE), nt_pioneer = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE_PI == TRUE], na.rm = TRUE), nt_shortlived = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TYPE_SL == TRUE], na.rm = TRUE), pi_hw_notoler_ExclSchool = 100 * sum(N_TAXA[HABITAT_HW_noT == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_wetland_notoler_ExclSchool = 100 * sum(N_TAXA[HABITAT_WE_noT == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_natcoldwater_ExclSchool = 100 * sum(N_TAXA[HABITAT_CWN == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_ma2_ExclShool = 100 * sum(N_TAXA[REPRO_MA2 == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_ma3_notoler_ExclSchool = 100 * sum(N_TAXA[REPRO_MA3_noT == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_nonlithophil_ExclSchool = 100 * sum(N_TAXA[REPRO_NE == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_serialspawner_ExclSchool = 100 * sum(N_TAXA[REPRO_SER == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_simplelithophil_ExclSchool = 100 * sum(N_TAXA[REPRO_SILI == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_detritivore_ExclSchool = 100 * sum(N_TAXA[TROPHIC_DE == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_gen_ExclSchool = 100 * sum(N_TAXA[TROPHIC_GE == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_herbivore_ExclSchool = 100 * sum(N_TAXA[TROPHIC_HB == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_insctCypr_ExclSchool = 100 * sum(N_TAXA[TROPHIC_IN_CYP == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_insectivore_notoler_ExclSchool = 100 * sum(N_TAXA[TROPHIC_IN_noT == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_piscivore_ExclSchool = 100 * sum(N_TAXA[TROPHIC_PI == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_intol_ExclSchool = 100 * sum(N_TAXA[TOLER_I == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_intolcoldwater_ExclSchool = 100 * sum(N_TAXA[TOLER_ICW == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_sens_ExclSchool = 100 * sum(N_TAXA[TOLER_S == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_senscoldwater_ExclSchool = 100 * sum(N_TAXA[TOLER_SCW == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_toler_ExclSchool = 100 * sum(N_TAXA[TOLER_T == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_tv_tolercoldwater_ExclSchool = 100 * sum(N_TAXA[TOLER_TCW == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_exotic_ExclSchool = 100 * sum(N_TAXA[TYPE_EX == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_minnow_notoler_ExclSchool = 100 * sum(N_TAXA[TYPE_MIN_noT == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_Perciformes_ExclSchool = 100 * sum(N_TAXA[TYPE_PERC == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_pioneer_ExclShool = 100 * sum(N_TAXA[TYPE_PI == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_shortlived_ExclSchool = 100 * sum(N_TAXA[TYPE_SL == TRUE & TYPE_SCHOOL == FALSE], na.rm = TRUE)/ni_total_ExclSchool, pi_dom02_ExclSchool = 100 * max(ni_dom02_ExclSchool, na.rm = TRUE)/ni_total_ExclSchool, pt_natcoldwater = 100 * nt_natcoldwater/nt_total, pt_serialspawner = 100 * nt_serialspawner/nt_total, pt_simplelithophil = 100 * nt_simplelithophil/nt_total, pt_tv_sens = 100 * nt_tv_sens/nt_total, pt_tv_senscoldwater = 100 * nt_tv_senscoldwater/nt_total, pt_tv_toler = 100 * nt_tv_toler/nt_total, pt_tv_vtoler = 100 * nt_tv_vtoler/nt_total, pt_beninsct_notoler = 100 * nt_beninsct_notoler/nt_total, pt_detritivore = 100 * nt_detritivore/nt_total, pt_gen = 100 * nt_gen/nt_total, pt_insectivore_notoler = 100 * nt_insectivore_notoler/nt_total, pt_omnivore = 100 * nt_omnivore/nt_total, pt_darterscultpinsucker = 100 * nt_darterscultpinsucker/nt_total, pt_pioneer = 100 * nt_pioneer/nt_total, ni_m2_notoler = ni_total_notoler_mn/area_m2, pi_delt_ExclSchool = 100 * sum(N_ANOMALIES[TYPE_SCHOOL != TRUE], na.rm = TRUE)/ni_total_ExclSchool): ℹ In argument: `x_BCG_Mean = mean(TOLVAL2, na.rm = TRUE)`.
#> ℹ In group 1: `SAMPLEID = "CHGX-432-S-1111"`, `INDEX_NAME = "MBSS_2005_Fish"`,
#> `INDEX_CLASS = "EPIEDMONT"`, `SAMP_WIDTH_M = 1.5`, `SAMP_LENGTH_M = 75`.
#> Caused by error:
#> ! object 'TOLVAL2' not found
if (FALSE) {
# View Results
View(df_metric_values_fish)
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Example 5, periphyton (algae) metrics
# df_metric_values_periphyton <- metric.values(data_diatom_mmi_dev, "algae")
if (FALSE) {
# View Results
}