Skip to content

Commit

Permalink
style and docs: run devtools::document() and styler::style_pkg()
Browse files Browse the repository at this point in the history
  • Loading branch information
kellijohnson-NOAA committed Dec 10, 2023
1 parent e56b1c8 commit 0e4de12
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 67 deletions.
53 changes: 23 additions & 30 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,45 @@ Package: hakedataUSA
Title: Extract USA Data for Pacific Hake
Version: 2022.0.1
Authors@R: c(
person(given = c("Kelli", "F."),
family = "Johnson",
role = c("aut", "cre"),
email = "kelli.johnson@noaa.gov",
person(c("Kelli", "F."), "Johnson", , "kelli.johnson@noaa.gov", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5149-451X")),
person(given = c("Aaron", "M."),
family = "Berger",
role = "aut"),
person(given = c("Ian", "G."),
family = "Taylor",
role = "ctb"),
person(given = c("Alan", "C."),
family = "Hicks",
role = "ctb"),
person(given = c("Andi"),
family = "Stephens",
role = "ctb"))
Description: Extract data from the two data warehouses, i.e., North Pacific Database (NORPAC) and Pacific Fisheries Information Network (PacFIN), used to store data for the Pacific Fisheries Management Council (PFMC).
person(c("Aaron", "M."), "Berger", role = "aut"),
person(c("Ian", "G."), "Taylor", role = "ctb"),
person(c("Alan", "C."), "Hicks", role = "ctb"),
person("Andi", "Stephens", role = "ctb")
)
Description: Extract data from the two data warehouses, i.e., North
Pacific Database (NORPAC) and Pacific Fisheries Information Network
(PacFIN), used to store data for the Pacific Fisheries Management
Council (PFMC).
License: What license it uses
Encoding: UTF-8
LazyData: true
Suggests:
knitr,
rmarkdown,
RODBC,
testthat
Depends:
R (>= 2.10)
Imports:
magrittr,
dplyr,
fs,
ggplot2,
glue,
graphics,
grDevices,
magrittr,
mapdata,
maps,
plyr,
RColorBrewer,
r4ss,
RColorBrewer,
readxl,
stats,
tidyr,
tools
Suggests:
knitr,
rmarkdown,
RODBC,
testthat
Remotes:
github::r4ss/r4ss
RoxygenNote: 7.2.3
github::r4ss/r4ss
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Depends:
R (>= 2.10)
RoxygenNote: 7.2.3
4 changes: 2 additions & 2 deletions R/plot_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ get_depth_by_year <- function(d,
median = 4,
upperhinge = 5, upper95 = 6
)
if(!is.null(yrs)){
if (!is.null(yrs)) {
dpth <- dpth %>%
dplyr::filter(year %in% yrs)
}
Expand All @@ -62,7 +62,7 @@ get_rate_by_month <- function(d,
median = 5,
upperhinge = 6, upper95 = 7
)
if(!is.null(yrs)){
if (!is.null(yrs)) {
dpth <- dpth %>%
dplyr::filter(year %in% yrs)
}
Expand Down
4 changes: 2 additions & 2 deletions R/process_age-.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ process_age_sea <- function(atsea.ages = get_local(file = "atsea.ages.Rdat"),
dplyr::mutate(dplyr::across(
dplyr::everything(),
.fns = \(x) tidyr::replace_na(x, 0)
))|>
)) |>
tidyr::nest(gg = -"vesseltype") |>
dplyr::mutate(
lower_name = tolower(vesseltype),
Expand Down Expand Up @@ -153,7 +153,7 @@ process_age_shore <- function(page = get_local("page.Rdat"),
dplyr::mutate(dplyr::across(
dplyr::everything(),
.fns = \(x) tidyr::replace_na(x, 0)
))|>
)) |>
utils::write.csv(
file = fs::path(hakedata_wd(), "us-sb-age-raw.csv"),
row.names = FALSE,
Expand Down
1 change: 0 additions & 1 deletion R/process_catch-.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ process_catch_norpac <- function(ncatch = get_local(file = "norpac_catch.Rdat"),
process_catch_pacfin <- function(pcatch = get_local(file = "pacfin_catch.Rdat"),
nyears = 5,
savedir = hakedata_wd()) {

# FLEET XXX is in the hake assessment as shore-based catches,
# although 1986 differs from data used
# database 1986 3431.9436
Expand Down
48 changes: 24 additions & 24 deletions R/process_weight_at_age-.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ process_weight_at_age_survey <- function(savedir = hakedata_wd()) {
# Custom function only needed inside this function for survey data
read_mutate_join <- function(x, y) {
if (!grepl("xlsx", x)) {
x_data <- suppressWarnings(readxl::read_xls(x))
y_data <- suppressWarnings(readxl::read_xls(y))
x_data <- suppressWarnings(readxl::read_xls(x))
y_data <- suppressWarnings(readxl::read_xls(y))
} else {
x_data <- suppressWarnings(readxl::read_excel(x))
y_data <- suppressWarnings(readxl::read_excel(y))
Expand Down Expand Up @@ -48,24 +48,24 @@ process_weight_at_age_survey <- function(savedir = hakedata_wd()) {
yy,
by = "haul"
) |>
dplyr::transmute(
Source = dplyr::case_when(
basename(dirname(x)) == "US" ~ "U.S. Acoustic",
basename(dirname(x)) == "CAN" ~ "Canada Acoustic",
TRUE ~ "Unknown Acoustic"
),
Weight_kg = weight,
Sex = Sex2,
Age_yrs = age,
Length_cm = length,
Month = as.numeric(format(as.Date(hb_date_time, f = "%m/%d/%Y"), "%m")),
Year = as.numeric(format(as.Date(hb_date_time, f = "%m/%d/%Y"), "%Y"))
) |>
dplyr::mutate(
Year = ifelse(Year < 2000, Year + 2000, Year)
) |>
dplyr::filter(!is.na(Age_yrs)) |>
dplyr::filter(!is.na(Weight_kg))
dplyr::transmute(
Source = dplyr::case_when(
basename(dirname(x)) == "US" ~ "U.S. Acoustic",
basename(dirname(x)) == "CAN" ~ "Canada Acoustic",
TRUE ~ "Unknown Acoustic"
),
Weight_kg = weight,
Sex = Sex2,
Age_yrs = age,
Length_cm = length,
Month = as.numeric(format(as.Date(hb_date_time, f = "%m/%d/%Y"), "%m")),
Year = as.numeric(format(as.Date(hb_date_time, f = "%m/%d/%Y"), "%Y"))
) |>
dplyr::mutate(
Year = ifelse(Year < 2000, Year + 2000, Year)
) |>
dplyr::filter(!is.na(Age_yrs)) |>
dplyr::filter(!is.na(Weight_kg))
stopifnot(!any(is.na(together[["Year"]])))
return(together)
}
Expand All @@ -84,7 +84,7 @@ process_weight_at_age_survey <- function(savedir = hakedata_wd()) {
"/20[12][0-9]/[CANUS]{2,3}|/2009/[CANUS]{2,3}",
value
)
) |>
) |>
dplyr::mutate(
bio_file = purrr::map_chr(
value,
Expand Down Expand Up @@ -223,9 +223,9 @@ process_weight_at_age <- function(dir = hakedata_wd(),
# save on size, contains all US samples in LWAdata_1975to2007.csv, so
# eliminated that file.
files_weights <- fs::path(
ext = "csv",
dir,
c("survey-weight-at-age", "us-weight-at-age", "can-weight-at-age")
ext = "csv",
dir,
c("survey-weight-at-age", "us-weight-at-age", "can-weight-at-age")
)
dat <- purrr::map_dfr(
files_weights,
Expand Down
14 changes: 7 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ for the assessment of Pacific Hake.
1. Next, load the package. This can be accomplished through GitHub (first
chunk) or using a local clone (second chunk).
```{r installation-github}
chooseCRANmirror(ind = 1)
# install.packages("pak")
pak::pak("pacific-hake/hakedataUSA")
library(hakedataUSA)
chooseCRANmirror(ind = 1)
# install.packages("pak")
pak::pak("pacific-hake/hakedataUSA")
library(hakedataUSA)
```
```{r installation-local}
chooseCRANmirror(ind = 1)
stopifnot(basename(getwd()) == "hakedataUSA")
devtools::load_all()
chooseCRANmirror(ind = 1)
stopifnot(basename(getwd()) == "hakedataUSA")
devtools::load_all()
```
1. The path to where all of the raw output will be saved is stored in an
internal function, i.e., `hakedata_wd()`. Try it out, see if it works for
Expand Down
2 changes: 1 addition & 1 deletion man/process_weight_at_age.Rd

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

0 comments on commit 0e4de12

Please sign in to comment.