Uncountedyears: Detect dates when a species was not counted

View source: R/Uncountedyears.R

UncountedyearsR Documentation

Detect dates when a species was not counted

Description

Detects years when a species was present in the system (i.e., post-invasion for invasive species) but not counted in each zooplankton survey

Usage

Uncountedyears(Source, Size_class, Crosswalk, Start_year, Intro_lag)

Arguments

Source

String with the name of the source dataset (e.g., Source="EMP").

Size_class

String with the name of the desired zooplankton size class (e.g., Source="Meso").

Crosswalk

Crosswalk table like crosswalk or another table in the same format.

Start_year

First year the Source survey started sampling zooplankton.

Intro_lag

Number of years buffer after a species is introduced when we expect surveys to start recording them. Effectively adds Intro_lag years to the introduction year of each species.

Details

This function is designed to work on one source and size class at a time. To apply across multiple IDs, use the map or apply functions.

Value

A tibble with columns for the Taxlifestage, Taxname, Lifestage, Source, Sizeclass, and then a list-column of years in which that particular taxon was not counted in the specified study and size class. Taxa that were counted in all applicable years are not included in the tibble.

Author(s)

Sam Bashevkin

See Also

Zoopsynther, crosswalk, startDates

Examples

require(purrr)
require(dplyr)
require(lubridate)

datasets<-zooper::zoopComb%>%
 mutate(names=paste(Source, SizeClass, sep="_"))%>%
 select(names, Source, SizeClass)%>%
 filter(Source%in%c("EMP", "FMWT", "twentymm"))%>%
 distinct()

BadYears<-map2_dfr(datasets$Source, datasets$SizeClass, ~ Uncountedyears(Source = .x,
Size_class = .y,
Crosswalk = zooper::crosswalk,
Start_year = zooper::startDates%>%
 filter(Source==.x & SizeClass==.y)%>%
 pull(Startdate)%>%
 year(),
 Intro_lag=2))

InteragencyEcologicalProgram/zooper documentation built on Feb. 6, 2025, 9:01 a.m.