Skip to content

Commit

Permalink
Split IPHC into set and catch dfs
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed May 31, 2024
1 parent f32dcc7 commit dc4b326
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 17 deletions.
16 changes: 14 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' Data from 1996 and 1997 come from local spreadsheets as described in
#' \pkg{gfiphc}.
#'
#' @format A data frame with these columns:
#' @format Once the 2 data frames are joined, a data frame with these columns:
#' \describe{
#' \item{year}{Year}
#' \item{station}{Station ID}
Expand All @@ -49,7 +49,19 @@
#' \item{depth_m}{Depth in m}
#' \item{species_common_name}{Species common name}
#' }
"iphc"
#'
#' @details
#' One likely wants to join the data frames. E.g.
#'
#' ```
#' iphc <- dplyr::inner_join(iphc_catch, iphc_sets)
#' ```
#'
#' @rdname iphc
"iphc_sets"

#' @rdname iphc
"iphc_catch"

#' Active survey blocks
#'
Expand Down
5 changes: 4 additions & 1 deletion data-raw/iphc-compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
library(dplyr)
library(ggplot2)

load("data/iphc.rda")
load("data/iphc_catch.rda")
load("data/iphc_sets.rda")
gfiphc_dat <- readRDS("data-raw/gfiphc-dogfish-setcounts.rds") |>
mutate(standard = as.character(standard))

iphc <- inner_join(iphc_catch, iphc_sets, by = join_by(year, station, station_key))

# visual comparison -----------------------------------------

x1 <- filter(gfiphc_dat, usable == "Y", standard == "Y")
Expand Down
63 changes: 49 additions & 14 deletions data-raw/iphc-simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ dat <- bind_rows(dat, never_caught_non_halibut)
# build a df of all possible stations and years for every species
full <- select(
dat, year, station, station_key, longitude, latitude,
hooks_observed, avg_no_hook_per_skate, no_skates_hauled,
hooks_observed, avg_no_hook_per_skate, no_skates_hauled, no_skates_set, effective_skates,
sample_type, usable, soak_time_min, temp_c, depth_m
) |> distinct()
full <- purrr::map_dfr(
Expand Down Expand Up @@ -406,23 +406,46 @@ plot_map(dat_all, temp_c) + scale_colour_viridis_c()

# save it! ------------------------------------------------------------------

attr(dat_all, "iphc_download_date") <- DOWNLOAD_DATE
attr(dat_all, "data_preparation_date") <- lubridate::today()
# saveRDS(dat_all, file = "report/iphc-simple/iphc-pbs.rds")

# order nicely:
iphc <- select(
# # order nicely:
# iphc <- select(
# dat_all,
# year,
# station,
# station_key,
# longitude,
# latitude,
# species_common_name,
# species_science_name,
# usable,
# hooks_observed,
# number_observed,
# pbs_standard_grid,
# inside_wcvi,
# sample_type,
# depth_m,
# temp_c,
# soak_time_min,
# avg_no_hook_per_skate,
# no_skates_hauled,
# no_skates_set,
# effective_skates
# )

# iphc_sets <- select(dat_all, -species_common_name, -species_science_name, -number_observed) |>
# distinct()
# iphc_catch <- select(dat_all, station_keyspecies_common_name, species_science_name, number_observed) |>
# distinct()

iphc_sets <- select(
dat_all,
year,
station,
station_key,
longitude,
latitude,
species_common_name,
species_science_name,
usable,
hooks_observed,
number_observed,
pbs_standard_grid,
inside_wcvi,
sample_type,
Expand All @@ -433,11 +456,23 @@ iphc <- select(
no_skates_hauled,
no_skates_set,
effective_skates
) |> distinct()

iphc_catch <- select(
dat_all,
year,
station,
station_key,
species_common_name,
species_science_name,
number_observed
)

# iphc_sets <- select(dat_all, -species_common_name, -species_science_name, -number_observed) |>
# distinct()
# iphc_catch <- select(dat_all, station_keyspecies_common_name, species_science_name, number_observed) |>
# distinct()
attr(iphc_sets, "iphc_download_date") <- DOWNLOAD_DATE
attr(iphc_sets, "data_preparation_date") <- lubridate::today()

attr(iphc_catch, "iphc_download_date") <- DOWNLOAD_DATE
attr(iphc_catch, "data_preparation_date") <- lubridate::today()

usethis::use_data(iphc, overwrite = TRUE)
usethis::use_data(iphc_sets, overwrite = TRUE)
usethis::use_data(iphc_catch, overwrite = TRUE)
Binary file added data/iphc_catch.rda
Binary file not shown.
Binary file added data/iphc_sets.rda
Binary file not shown.
48 changes: 48 additions & 0 deletions man/iphc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc4b326

Please sign in to comment.