knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
# remotes::install_github("fishvice/tidydatras", ref = "e5d9a0a", force = TRUE, 
#                         quiet = TRUE, dependencies = FALSE)
library(tidyverse)
library(tidydatras)
# this take a while, ... but it (supposedly) is downloading and calculating
#  cpue by length for all species.
d <- dr_doodle(survey_quarter = "FR-CGFS_4", years = 2005:2022)
# d <- dr_doodle(survey_quarter = "NS-IBTS_1", years = 2000:2022)
# d <- res
# only looking at one species, but the rest are there
d |> 
  mutate(B = n * 0.00001 * length^3) |> 
  group_by(vessel, id, year, english_name) |>
  # group_by(id, year, english_name) |> 
  summarise(B = sum(B),
            .groups = "drop") |> 
  filter(english_name %in% c("Surmullet", "Atlantic mackerel", "Red gurnard", "Grey gurnard", "Whiting", "Common cuttlefish",
                             "Atlantic horse mackerel")) |> 

  ggplot(aes(year, B, colour = vessel)) +
  # ggplot(aes(year, B)) +
  theme_bw() +
  stat_summary(fun.data = "mean_cl_boot") +
  facet_wrap(~ english_name, scales = "free_y") +
  expand_limits(y = 0) +
  scale_colour_brewer(palette = "Set1") +
  facet_wrap(~ english_name, scales = "free_y") +
  scale_y_continuous(breaks = scales::pretty_breaks()) +
  facet_wrap(~english_name, scales="free_y")


fishvice/tidyices documentation built on Sept. 12, 2023, 4:22 p.m.