Skip to content

Commit db5ea47

Browse files
Merge pull request #42 from NEFSC/dev
Dev
2 parents e0a22ea + 552ed60 commit db5ea47

618 files changed

Lines changed: 13684 additions & 2733 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R-CMD-check.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
workflow_dispatch:
5+
6+
name: R-CMD-check.yaml
7+
8+
permissions: read-all
9+
10+
jobs:
11+
R-CMD-check:
12+
runs-on: ${{ matrix.config.os }}
13+
14+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
config:
20+
- {os: macos-latest, r: 'release'}
21+
- {os: windows-latest, r: 'release'}
22+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
23+
- {os: ubuntu-latest, r: 'release'}
24+
- {os: ubuntu-latest, r: 'oldrel-1'}
25+
26+
env:
27+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
28+
R_KEEP_PKG_SOURCE: yes
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: r-lib/actions/setup-pandoc@v2
34+
35+
- uses: r-lib/actions/setup-r@v2
36+
with:
37+
r-version: ${{ matrix.config.r }}
38+
http-user-agent: ${{ matrix.config.http-user-agent }}
39+
use-public-rspm: true
40+
41+
- uses: r-lib/actions/setup-r-dependencies@v2
42+
with:
43+
extra-packages: any::rcmdcheck
44+
needs: check
45+
46+
- uses: r-lib/actions/check-r-package@v2
47+
with:
48+
upload-snapshots: true
49+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

DESCRIPTION

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,68 @@
11
Package: NEesp2
22
Title: Generates ESP Reports for the Northeast
33
Version: 0.1.1
4-
Description: Generates indicators, visualizations, and reports for NEFSC Ecosystem and Socioeconomic Profiles.
5-
License: file LICENSE
6-
Authors@R: c(person("Abigail", "Tyrell", email = "abigail.tyrell@noaa.gov", role = c("aut", "cre"),
4+
Authors@R: c(
5+
person("Abigail", "Tyrell", , "abigail.tyrell@noaa.gov", role = c("aut", "cre"),
76
comment = c(ORCID = "0000-0002-6656-8470")),
8-
person("Stephanie", "Owen", email = "stephanie.owen@noaa.gov", role = "aut"))
7+
person("Stephanie", "Owen", , "stephanie.owen@noaa.gov", role = "aut")
8+
)
99
Maintainer: Abigail Tyrell <abigail.tyrell@noaa.gov>
10+
Description: Generates indicators, visualizations, and reports for NEFSC
11+
Ecosystem and Socioeconomic Profiles.
12+
License: file LICENSE
1013
URL: https://nefsc.github.io/READ-EDAB-NEesp2/
1114
BugReports: https://github.com/NEFSC/READ-EDAB-NEesp2/issues
15+
Depends:
16+
R (>= 3.5.0)
17+
Imports:
18+
magrittr,
19+
rlang
1220
Suggests:
21+
assessmentdata,
1322
bookdown,
1423
deps,
24+
devtools,
1525
dplyr,
1626
DT,
1727
ecodata,
28+
EDABUtilities,
1829
flextable,
30+
FSA,
1931
ggnewscale,
2032
ggplot2,
2133
ggpubr,
34+
ggrepel,
2235
ggridges,
2336
ggthemes,
2437
here,
2538
knitr,
26-
magrittr,
39+
lintr,
40+
lwgeom,
2741
nmfspalette,
28-
rlang,
42+
pander,
43+
papeR,
44+
priceR,
2945
rmarkdown,
3046
scales,
3147
sf,
3248
stringr,
33-
tibble,
49+
survdat,
50+
testthat (>= 3.0.0),
51+
tibble,
3452
tidyquant,
3553
tidyr,
3654
utils,
37-
viridis,
38-
assessmentdata,
39-
FSA,
40-
ggrepel,
41-
pander,
42-
papeR,
43-
priceR,
44-
testthat (>= 3.0.0),
45-
lintr
55+
viridis
56+
VignetteBuilder:
57+
rmarkdown
4658
Remotes:
59+
NEFSC/READ_EDAB_Utilities,
4760
nmfs-general-modeling-tools/nmfspalette,
61+
NOAA-EDAB/assessmentdata,
4862
NOAA-EDAB/ecodata,
49-
NOAA-EDAB/assessmentdata
50-
VignetteBuilder:
51-
knitr
63+
NOAA-EDAB/survdat
64+
Config/testthat/edition: 3
5265
Encoding: UTF-8
5366
LazyData: true
5467
Roxygen: list(markdown = TRUE)
55-
Depends:
56-
R (>= 3.5.0)
57-
Config/testthat/edition: 3
5868
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(add_fig_paths)
4-
export(create_chl)
54
export(create_coldpool_extent)
65
export(create_coldpool_index)
76
export(create_coldpool_persistence)
87
export(create_gsi)
98
export(create_mrip_trips)
109
export(create_prop_sp_trips)
1110
export(create_spatial_indicator)
12-
export(create_sst)
1311
export(create_template)
1412
export(create_total_mrip)
1513
export(create_wcr)

R/create_condition_indicator.R

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,32 @@
99
#' @param by_EPU logical. If TRUE, calculates condition by EPUs specified in the input data, if FALSE, calculates condition for all data combined.
1010
#' @param by_sex logical. If TRUE, calculates condition by sex. If FALSE, calculates condition across sexes.
1111
#' @param length_break numeric vector. If not NULL, will calculate condition by length breaks specified in the vector. User must specify minimum and maximum lengths in this parameter, e.g., c(0, 20, 70). If NULL, will not calculate by length groupings.
12+
#' @param more_than_20_years logical. If TRUE, only returns species with 20 or more years of data.
13+
#' @param record_outliers logical. If TRUE, returns a list with two data frames: the first is the condition data frame, the second is a data frame of outliers that were removed from the analysis. If FALSE, only returns the condition data frame.
1214
#' @param output character. If "soe", returns a data frame of species condition for the State of the Ecosystem report. If "esp", returns a data frame for ESPs. If "full", returns a data frame of all calculated values. *Setting by_sex = TRUE or length_break to any value will always return a full dataframe*
1315
#' @importFrom magrittr %>%
1416
#' @return Returns a data frame of species condition
1517
#' @export
1618

17-
species_condition <- function(data,
18-
LWparams = NEesp2::LWparams,
19-
species.codes = NEesp2::species.codes,
20-
by_EPU = TRUE,
21-
by_sex = FALSE,
22-
length_break = NULL,
23-
output = "soe") {
24-
if (by_sex |
25-
!is.null(length_break)) {
19+
species_condition <- function(
20+
data,
21+
LWparams = NEesp2::LWparams,
22+
species.codes = NEesp2::species.codes,
23+
by_EPU = TRUE,
24+
by_sex = FALSE,
25+
length_break = NULL,
26+
more_than_20_years = TRUE,
27+
record_outliers = FALSE,
28+
output = "soe"
29+
) {
30+
if (
31+
by_sex |
32+
!is.null(length_break)
33+
) {
2634
if (output != "full") {
27-
message("You asked to group results by sex and/or length ; data will not be formatted for SOE or ESP output.")
35+
message(
36+
"You asked to group results by sex and/or length ; data will not be formatted for SOE or ESP output."
37+
)
2838
}
2939
output <- "full"
3040
}
@@ -71,18 +81,24 @@ species_condition <- function(data,
7181

7282
# Add SEX for Combined gender back into Wigley at all data (loses 4 Gender==Unsexed):
7383
LWpar_sexed <- new_dat |>
74-
dplyr::mutate(sex = dplyr::case_when(
75-
Gender == "Combined" | Gender == "Unsexed" ~ as.character(0),
76-
Gender == "Male" ~ as.character(1),
77-
Gender == "Female" ~ as.character(2),
78-
TRUE ~ NA
79-
))
84+
dplyr::mutate(
85+
sex = dplyr::case_when(
86+
Gender == "Combined" | Gender == "Unsexed" ~ as.character(0),
87+
Gender == "Male" ~ as.character(1),
88+
Gender == "Female" ~ as.character(2),
89+
TRUE ~ NA
90+
)
91+
)
8092

8193
LWpar_spp <- LWpar_sexed %>%
8294
dplyr::mutate(SVSPP = as.numeric(LW_SVSPP))
8395

8496
# Join survdat data with LW data
85-
mergedata <- dplyr::left_join(fall, LWpar_spp, by = c("SEASON", "SVSPP", "sex"))
97+
mergedata <- dplyr::left_join(
98+
fall,
99+
LWpar_spp,
100+
by = c("SEASON", "SVSPP", "sex")
101+
)
86102

87103
# filters out values without losing rows with NAs:
88104
mergewt <- dplyr::filter(mergedata, is.na(INDWT) | INDWT < 900)
@@ -102,7 +118,8 @@ species_condition <- function(data,
102118
###########################################
103119
### Calculate species condition ###
104120

105-
condcalc <- dplyr::mutate(mergeLW,
121+
condcalc <- dplyr::mutate(
122+
mergeLW,
106123
predwt = (exp(lna)) * LENGTH^b,
107124
RelCond = INDWT / predwt
108125
) |>
@@ -111,7 +128,23 @@ species_condition <- function(data,
111128
dplyr::mutate(mean = mean(RelCond), sd = sd(RelCond)) |>
112129
dplyr::ungroup() |>
113130
# might want to update this outlier removal eventually
114-
dplyr::filter(RelCond < (mean + (2 * sd)) & RelCond > (mean - (2 * sd))) |>
131+
dplyr::mutate(
132+
outlier = RelCond > (mean + (2 * sd)) | RelCond < (mean - (2 * sd))
133+
)
134+
135+
message(paste0(
136+
"Removing ",
137+
sum(condcalc$outlier, na.rm = TRUE),
138+
" outliers from the data set."
139+
))
140+
141+
if (record_outliers) {
142+
outliers <- condcalc |>
143+
dplyr::filter(outlier == TRUE)
144+
}
145+
146+
condcalc <- condcalc |>
147+
dplyr::filter(outlier == FALSE) |>
115148
dplyr::filter(is.na(sex) | sex != 4) %>%
116149
dplyr::mutate(sexMF = sex)
117150

@@ -145,11 +178,18 @@ species_condition <- function(data,
145178
# select columns
146179
dplyr::select(dplyr::all_of(c(grouping_vars, "MeanCond", "nCond"))) |>
147180
# group again, without YEAR
148-
dplyr::group_by(!!!rlang::syms(grouping_vars[-which(grouping_vars == "YEAR")])) |>
181+
dplyr::group_by(
182+
!!!rlang::syms(grouping_vars[-which(grouping_vars == "YEAR")])
183+
) |>
149184
# filter to only species with 20+ years of data
150-
dplyr::mutate(n = dplyr::n()) |>
151-
dplyr::filter(n >= 20) |>
152-
dplyr::select(-n) |>
185+
dplyr::mutate(n = dplyr::n())
186+
187+
if (more_than_20_years) {
188+
condition <- condition |>
189+
dplyr::filter(n >= 20) |>
190+
dplyr::select(-n)
191+
}
192+
condition <- condition |>
153193
# calculate sd and variance across years
154194
dplyr::mutate(
155195
sd = sd(MeanCond, na.rm = TRUE),
@@ -174,5 +214,9 @@ species_condition <- function(data,
174214
dplyr::select(Species, EPU, YEAR, MeanCond, INDICATOR_NAME) |>
175215
dplyr::rename(DATA_VALUE = MeanCond)
176216
}
217+
218+
if (record_outliers) {
219+
condition <- list(condition = condition, outliers = outliers)
220+
}
177221
return(condition)
178222
}

R/create_recreational_indicators.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ create_total_mrip <- function(
4343
DATA_VALUE = total_rec_catch$data_value |>
4444
stringr::str_remove_all(",") |>
4545
as.numeric(),
46+
LOWER_95_CI = total_rec_catch |>
47+
dplyr::select(dplyr::contains("LOWER")) |>
48+
dplyr::pull() |>
49+
stringr::str_remove_all(",") |>
50+
as.numeric(),
51+
UPPER_95_CI = total_rec_catch |>
52+
dplyr::select(dplyr::contains("UPPER")) |>
53+
dplyr::pull() |>
54+
stringr::str_remove_all(",") |>
55+
as.numeric(),
4656
CATEGORY = "Recreational",
4757
INDICATOR_TYPE = "Socioeconomic",
4858
INDICATOR_NAME = paste0("total_recreational_", var_name, "_", var_units),

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ files <- list.files(recursive = TRUE, all.files = TRUE) %>%
1717
stringr::str_subset(pattern = ".Renviron", negate = TRUE)
1818
total_size <- (sum(file.size(files))/1073741824) %>%
1919
stringr::str_trunc(width = 4, ellipsis = "")
20-
2120
cat(badger::badge_devel("NEFSC/READ-EDAB-NEesp2", "blue"),
2221
badger::badge_last_commit("NEFSC/READ-EDAB-NEesp2"),
2322
badger::badge_custom("repo size", paste(total_size, "GB"), color = "blue", url = "https://github.com/NEFSC/READ-EDAB-NEesp2"),
2423
sep = "\n")
2524
```
2625
[![](https://github.com/NEFSC/READ-EDAB-NEesp2/workflows/gitleaks/badge.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/secretScan.yml)
26+
[![R-CMD-check](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/R-CMD-check.yaml)
2727
<!-- badges: end -->
2828

2929
# Ecosystem and Socioeconomic Profiles

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
[![](https://img.shields.io/badge/devel%20version-0.1.1-blue.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2)
55
[![](https://img.shields.io/github/last-commit/NEFSC/READ-EDAB-NEesp2.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2/commits/main)
6-
[![](https://img.shields.io/badge/repo%20size-1.25%20GB-blue.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2)
6+
[![](https://img.shields.io/badge/repo%20size-0.60%20GB-blue.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2)
77
[![](https://github.com/NEFSC/READ-EDAB-NEesp2/workflows/gitleaks/badge.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/secretScan.yml)
8+
[![R-CMD-check](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/NEFSC/READ-EDAB-NEesp2/actions/workflows/R-CMD-check.yaml)
89
<!-- badges: end -->
910

1011
# Ecosystem and Socioeconomic Profiles
@@ -72,14 +73,14 @@ templates will be added shortly.
7273
<col style="width: 33%" />
7374
</colgroup>
7475
<thead>
75-
<tr class="header">
76+
<tr>
7677
<th><a href="https://github.com/atyrell3">atyrell3</a></th>
7778
<th><a href="https://github.com/stephanie-owen">stephanie-owen</a></th>
7879
<th></th>
7980
</tr>
8081
</thead>
8182
<tbody>
82-
<tr class="odd">
83+
<tr>
8384
<td><a href="https://github.com/atyrell3"><img
8485
src="https://avatars.githubusercontent.com/u/77738923?s=100&amp;u=92e54f60ca179f3e41c1a3610fb3ecdb9e233434&amp;v=4" /></a></td>
8586
<td><a href="https://github.com/stephanie-owen"><img

_pkgdown.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ navbar:
3535
href: articles/using_mrip_data.html
3636
- text: "Using {survdat} for Bottom Trawl Indicators"
3737
href: articles/using_survdat_data.html
38+
- text: "Comparison of condition data methods"
39+
href: articles/compare_condition.html
3840
- text: "Functions"
3941
href: reference/index.html
4042
- text: "News"

data-raw/Survdat_2024.RData

11.7 MB
Binary file not shown.
-1.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)