SPDTdata: SPDTdata

View source: R/SPDTdata.R

SPDTdataR Documentation

SPDTdata

Description

A function to filter and format SLD data to cases with clipped experimental stocking groups. Function only usable by FFSBC staff who have a direct or vpn connection to SLD.

Usage

SPDTdata(
  Spp = NULL,
  Contrast = NULL,
  Controls = c("Species", "Geno_rel", "Strain_rel", "SAR_cat"),
  Strains = NULL,
  Genotypes = NULL,
  filters = NULL,
  Data_source = TRUE
)

Arguments

Spp

an optional character string or character vector for BC species code (e.g. "RB" or c("KO", "EB"), etc.). This will filter data to only that species.

Contrast

a required character string describing the experimental contrast, which must be a field in the SPDTdata (e.g. "Species", "Strain", "SAR_cat", "Genotype" are the 3 possibilities now). Entering a value for contrast will filter to lake years that had fish present from a co-stocking event of groups varying in your contrast variable.

Controls

an optional character vector to assign controls (grouping variables) that must be met to compare the "Contrast" groups. Default is the full list of potential contrasts. Using all controls may be restrictive for some contrasts (eg. Comparing species it would be difficulat to control for size-at-release SAR_cat becasue they are released at differnet stage-sizes)

Strains

an optional character string or character vector describing the strain code (SPDTdata format e.g. "RB" for Rainbow Trout) for source population. This will filter to only those strains listed

Genotypes

an optional character string or character vector to filter data to specific genotypes (e.g. 2n or AF3n)

filters

a vector of lake-years returned from the SPDTfilter() function. SPDTfilter() allows for filtering to various non-biological aspects to the data, lakes, years, regions, et.c See?SPDTfilter()

Data_source

a TRUE FALSE value to indicate whether to load data form the SLD, or just use data tables in the Environment.

Details

This is the final data filtering and cleaning process after SLD2R(), and linkClips(). These two previous functions are called within this function, so there is no need to repeat. This function returns the data tables from linkClips, plus new refined data sets. "idf" is the individual level data frame, for all clipped fish meeting your filtering selections. "gdf" is the grouped data frame, for all clipped groups meeting your filtering selections. Our database will not likely ever have filtered summaries to this level, so this function will be used and updated in to the future.

Several new columns are present. Anything prefixed by "NetX" means that variable has been expanded to account for gillnet selectivity. SAR if for size-at-release in grams, and SAR_cat has categorized those release sizes. The code creating categories for the SAR_cat has bigger categories as the size increases and is as follows:

dplyr::mutate(SAR_cat = dplyr::case_when(SAR<=6 ~ plyr::round_any(SAR,1), SAR>6&SAR<=14.5 ~ plyr::round_any(SAR,2), SAR>14.5&SAR<=27.5 ~ plyr::round_any(SAR,5), SAR>27.5&SAR<65 ~ plyr::round_any(SAR,10), TRUE ~ plyr::round_any(SAR, 25)) You could create our own categorical system and column if needed

Examples

#Must be connected to VPN if working remotely

#Download all data with clipped fish
SPDTdata()

#Download only KO data
SPDTdata(Spp = "KO")

#Download any data from RB, of either HF, CL or BW strain that were stocked as a strain comparison
SPDTdata(Spp = "RB", Strains = c("HF", "CL", "BW"), Contrast = "Strain")

#Download all data from lake years that had a size-at-release comparison for RB
SPDTdata(Spp = "RB", Contrast = "SAR_cat")


PAskey/SPDT documentation built on May 31, 2024, 12:21 a.m.