
Catch, presence and absence per FDIS site visit and species
Source:R/fdis_species.R
knw_fdis_species.RdOne row per visit and species in species: how many were caught (summed
over the codes that count as that species), how many of them were measured
into each size class of breaks, whether the species is present, and whether
an absence claim is blocked by a code that could hide it.
Usage
knw_fdis_species(
sites,
catch,
fish,
codes,
breaks,
species = knw_species(),
pooled = NULL
)Arguments
- sites
data.framewithsite_visit,watershed_group_code,yearandcatch_status.- catch
data.framewithsite_visit,species_code,n_caughtandn_measured(0230'scatch.rds).- fish
data.framewithsite_visit,species_codeandlength_mm(0230'sfish.rds).- codes
data.framewithcode,catch_class,species_groupandblocks_absence_of(data/fdis_species_codes.csv, read as character).- breaks
size-class breaks, as
knw_size_class()takes them.- species
characterspecies codes to keep rows for.- pooled
NULL, or adata.framewithwatershed_group_codeandobs_year_maxnaming the groups where DV records are pooled into BT, up to that year (NAfor no limit), aslink::lnk_species_pooling()reports them.
Value
A tibble with site_visit, species_code, n_caught,
n_measured, one n_<size_class> column per class in breaks,
n_unmeasured, pooling ("BT+DV" or "BT" for BT, NA otherwise),
present, absence_blocked and status (present, absent, blocked,
unknown).
Details
Presence follows scripts/0290's pooling rule for bull trout and the code
table for everything else:
a species is present when a code that counts as it was caught. For
BTthe codes areBTalone, or every char code exceptSLV(BT,DV,BT/DV,DV/BT,DVxBT) where link pools Dolly Varden records into bull trout for that watershed group and year (pooled);an absence is blocked when the visit caught a code whose
blocks_absence_ofnames the species or its species group (charfor BT), or, forBT, any other char code (DVcounts as a BT absence where DV is not pooled, as link counts it);a visit whose
catch_statusisunknowncarries no absence.
n_caught is NA where every counting code's count was a sentinel (caught,
abundance unknown). Size-class counts exist only for the species groups
breaks tiles (a measured fish of another species has a length and no
class); n_unmeasured is the counted fish with no usable length.
Examples
sites <- data.frame(site_visit = c("v1", "v2"), watershed_group_code = "BULK",
year = 2010L, catch_status = c("fish", "zero"))
catch <- data.frame(site_visit = c("v1", "v1"), species_code = c("DV", "CH"),
n_caught = c(3, 2), n_measured = c(2, 0))
fish <- data.frame(site_visit = "v1", species_code = c("DV", "DV"), length_mm = c(55, 120))
codes <- data.frame(code = c("DV", "CH", "BT"), catch_class = "fish",
species_group = c("char", "CH", "char"), blocks_absence_of = "")
breaks <- data.frame(species_group = c("char", "char"), size_class = c("fry", "juvenile"),
length_min_mm = c(0, 80), length_max_mm = c(80, Inf))
# DV is a BT absence unless pooled; pooling makes v1 a BT visit with 3 fish
knw_fdis_species(sites, catch, fish, codes, breaks, species = c("BT", "CH"))
#> # A tibble: 4 × 11
#> site_visit species_code n_caught n_measured n_fry n_juvenile n_unmeasured
#> <chr> <chr> <dbl> <dbl> <int> <int> <dbl>
#> 1 v1 BT 0 0 0 0 0
#> 2 v1 CH 2 0 0 0 2
#> 3 v2 BT 0 0 0 0 0
#> 4 v2 CH 0 0 0 0 0
#> # ℹ 4 more variables: pooling <chr>, present <lgl>, absence_blocked <lgl>,
#> # status <chr>
knw_fdis_species(sites, catch, fish, codes, breaks, species = "BT",
pooled = data.frame(watershed_group_code = "BULK", obs_year_max = NA))
#> # A tibble: 2 × 11
#> site_visit species_code n_caught n_measured n_fry n_juvenile n_unmeasured
#> <chr> <chr> <dbl> <dbl> <int> <int> <dbl>
#> 1 v1 BT 3 2 1 1 1
#> 2 v2 BT 0 0 0 0 0
#> # ℹ 4 more variables: pooling <chr>, present <lgl>, absence_blocked <lgl>,
#> # status <chr>