knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# load ---- library(swo)
This is a basic example which shows you how to query the data for the GOA or AI:
library(swo) yrs = 2017 # min year to consider species = c(10110, 21740) # AFSC species codes region = 'GOA' afsc_user = 'your_afsc_username' afsc_pwd = 'your_afsc_pwd' # query the database, results are stored in 4 files in the "data" folder query_data(region, species, yrs, afsc_user, afsc_pwd) # bring data into the global environment cpue <- vroom::vroom(here::here('data', 'cpue_goa.csv')) lfreq <- vroom::vroom(here::here('data', 'lfreq_goa.csv')) strata <- vroom::vroom(here::here('data', 'strata_goa.csv')) specimen <- vroom::vroom(here::here('data', 'specimen_goa.csv'))
Since the query will not work unless one is connect to the AFSC (and has associated permissions) some example data have been provided.
library(swo) # get data data(example_cpue) # numerical CPUE by species/year/haul/strata data(example_lfreq) # lengthed fish sample data data(example_specimen) # aged fish sample data data(example_strata) # survey strata area sizes km^2
In the following example a simple example of two replicates is run that incorporates: bootstrap haul, length, and age variability, and reduces the length sample size to 100 per haul.
The results are saved in nested folders output/goa
with file names example_comp_age.csv
etc.
swo_sim(iters = 2, example_lfreq, example_specimen, example_cpue, example_strata, boot_hauls = TRUE, boot_lengths = TRUE, boot_ages = TRUE, length_samples = 100, save = 'example', region = 'goa')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.