Skip to content

Commit d515bc1

Browse files
committed
debugging r cmd check
1 parent 81d1346 commit d515bc1

164 files changed

Lines changed: 145 additions & 468 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.

DESCRIPTION

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ BugReports: https://github.com/NEFSC/READ-EDAB-NEesp2/issues
1515
Depends:
1616
R (>= 3.5.0)
1717
Imports:
18-
magrittr,
19-
rlang
18+
magrittr,
19+
rlang
2020
Suggests:
2121
assessmentdata,
2222
bookdown,
@@ -38,11 +38,13 @@ Suggests:
3838
knitr,
3939
lintr,
4040
lwgeom,
41+
mockery,
4142
nmfspalette,
4243
pander,
4344
papeR,
4445
priceR,
4546
rmarkdown,
47+
rvest,
4648
scales,
4749
sf,
4850
stringr,
@@ -54,7 +56,7 @@ Suggests:
5456
utils,
5557
viridis
5658
VignetteBuilder:
57-
rmarkdown
59+
knitr
5860
Remotes:
5961
NEFSC/READ_EDAB_Utilities,
6062
nmfs-general-modeling-tools/nmfspalette,

R/create_recreational_indicators.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#' Input data is MRIP catch (A, B1, B2 catch combined)
55
#'
66
#' @param data The mrip data
7-
#' @param species The species common name
87
#' @param var_name The variable name to use in the indicator name. Default is "catch".
98
#' @param var_units The variable units to use in the indicator name. Default is "n".
109
#' @param remove_non_standard Boolean, if TRUE will remove non-standard data ("Does Total Catch (A+B1+B2) Meet MRIP Standard" = NO)
@@ -76,7 +75,7 @@ create_total_mrip <- function(
7675
#' Choose year of interest, summarize by Annual, Calendar Year, Atlantic coast by state, species of interest, all modes and areas, Primary Target
7776
#' Download csv as output
7877
#' @param files A list of the full file names of annual directed trip data (.csv format). Must download for each year in MRIP query tool.
79-
#' @param states States in which to filter data, from MRIP query 'ATLANTIC COAST BY STATE'
78+
#' @param remove_non_standard Boolean, if TRUE will remove non-standard data ("Does Directed Trips Meet MRIP Standard" = NO)
8079
#' @importFrom magrittr %>%
8180
#' @return Saves R object `rec_trips`, returns directed recreational trips indicator
8281
#' @export

R/create_template.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
#'
33
#' This function creates an ESP two-pager template at the specified path.
44
#' @param path Where to create the template. Defaults to the present working directory.
5+
#' @param over whether to overwrite existing files. Defaults to FALSE.
56
#' @export
67

7-
8-
create_template <- function(path = getwd(),
9-
over = FALSE) {
8+
create_template <- function(path = getwd(), over = FALSE) {
109
file.copy(
11-
from = list.files(path = system.file(c("esp_template"),
12-
package = "NEesp2"),
13-
# recursive = TRUE,
14-
full.names = TRUE),
10+
from = list.files(
11+
path = system.file(c("esp_template"), package = "NEesp2"),
12+
# recursive = TRUE,
13+
full.names = TRUE
14+
),
1515
to = path,
1616
recursive = TRUE,
1717
overwrite = over

R/get_mrip_data.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ save_trips <- function(
285285
#' @param out_folder where to save the data
286286
#' @param catch_type the type of catch to query. Can be "all" for all catch types (A, B1, B2), or "landings" for just the landings (A and B1). Default is "all".
287287
#' @param wait whether to pause after saving the data. Default is TRUE.
288-
#' @param return_fmane whether to return the file name of the saved data. Default is TRUE.
288+
#' @param return_fname whether to return the file name of the saved data. Default is TRUE.
289289
#' @return Saves list of the scraped data and metadata. Returns the file name.
290290
#' @export
291291

@@ -298,7 +298,6 @@ save_catch <- function(
298298
wait = TRUE,
299299
return_fname = TRUE
300300
) {
301-
302301
fname <- paste0(
303302
out_folder,
304303
"/catch_",

R/plot_condition.R

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,62 @@
1-
#' Plot Condition
1+
#' Plot Condition
22
#'
33
#' @param data A data frame of species condition from `species_condition(..., output = "soe")`
44
#' @param var species of interest to plot
55
#' @return A ggplot
6-
#'
6+
#'
77
#' @export
88

9-
plot_condition <- function(data,
10-
var,
11-
return = TRUE){
9+
plot_condition <- function(data, var) {
1210
condition <- data |>
13-
dplyr::select(YEAR,
14-
Species,
15-
EPU,
16-
DATA_VALUE) |>
11+
dplyr::select(YEAR, Species, EPU, DATA_VALUE) |>
1712
dplyr::group_by(Species) |>
18-
dplyr::mutate(scaleCond = scale(DATA_VALUE,scale =T,center=T))
19-
20-
xs <- quantile(condition$scaleCond, seq(0,1, length.out = 6), na.rm = TRUE)
21-
13+
dplyr::mutate(scaleCond = scale(DATA_VALUE, scale = T, center = T))
14+
15+
xs <- quantile(condition$scaleCond, seq(0, 1, length.out = 6), na.rm = TRUE)
16+
2217
condition <- condition |>
23-
dplyr::mutate(category = cut(scaleCond,
24-
breaks = xs,
25-
labels = c( "Poor Condition",
26-
"Below Average",
27-
"Neutral",
28-
"Above Average",
29-
"Good Condition"),
30-
include.lowest = TRUE))
31-
18+
dplyr::mutate(
19+
category = cut(
20+
scaleCond,
21+
breaks = xs,
22+
labels = c(
23+
"Poor Condition",
24+
"Below Average",
25+
"Neutral",
26+
"Above Average",
27+
"Good Condition"
28+
),
29+
include.lowest = TRUE
30+
)
31+
)
32+
3233
condition <- condition |>
3334
dplyr::filter(Species %in% var) |>
3435
dplyr::ungroup() |>
3536
dplyr::arrange(YEAR) |>
3637
dplyr::group_by(EPU) |>
37-
dplyr::mutate(mean = mean(DATA_VALUE, na.rm = TRUE),
38-
sd = sd(DATA_VALUE, na.rm = TRUE)) |>
39-
ggplot2::ggplot(ggplot2::aes(x = YEAR,
40-
y = DATA_VALUE,
41-
color = category,
42-
shape = EPU
38+
dplyr::mutate(
39+
mean = mean(DATA_VALUE, na.rm = TRUE),
40+
sd = sd(DATA_VALUE, na.rm = TRUE)
41+
) |>
42+
ggplot2::ggplot(ggplot2::aes(
43+
x = YEAR,
44+
y = DATA_VALUE,
45+
color = category,
46+
shape = EPU
4347
)) +
4448
ggplot2::geom_path(color = "black", lty = 2, alpha = 0.5) +
4549
ggplot2::geom_point(cex = 3) +
4650
ggplot2::xlim(c(1989, 2024)) +
4751
ggplot2::theme_classic(base_size = 16) +
48-
ggplot2::theme(strip.text = ggplot2::element_text(size = 16),
49-
axis.title.x = ggplot2::element_blank(),
50-
aspect.ratio = 0.4,
51-
legend.direction = "vertical",
52-
legend.box = "horizontal") +
52+
ggplot2::theme(
53+
strip.text = ggplot2::element_text(size = 16),
54+
axis.title.x = ggplot2::element_blank(),
55+
aspect.ratio = 0.4,
56+
legend.direction = "vertical",
57+
legend.box = "horizontal"
58+
) +
5359
viridis::scale_color_viridis(discrete = TRUE)
54-
60+
5561
return(condition)
5662
}
57-
58-

R/plot_indicator_ts.R

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,64 @@
1-
#' Plot indicator time series
1+
#' Plot indicator time series
22
#'
33
#' This function plots an indicator time series with a year, indicator name, and data value with mean and standard deviation lines.
44
#'
55
#' @param data A data frame with columns of YEAR, INDICATOR_NAME, and DATA_VALUE
66
#' @param ar Aspect Ratio for the resulting plot
7+
#' @param include_trends Boolean, if TRUE will include linear and GLS trend lines using ecodata package. Default is TRUE.
78
#' @return A ggplot
89
#' @importFrom magrittr %>%
910
#' @importFrom rlang .data
1011
#' @export
11-
#'
12-
plt_indicator <- function(data,
13-
ar = 1/4,
14-
include_trends = TRUE) {
12+
#'
13+
plt_indicator <- function(data, ar = 1 / 4, include_trends = TRUE) {
1514
plt <- data |>
1615
dplyr::group_by(INDICATOR_NAME) |>
17-
dplyr::mutate(mean = mean(DATA_VALUE, na.rm = TRUE),
18-
sd = sd(DATA_VALUE, na.rm = TRUE)) |>
19-
ggplot2::ggplot(ggplot2::aes(x = YEAR,
20-
y = DATA_VALUE
21-
)) +
22-
ggplot2::geom_hline(ggplot2::aes(
23-
yintercept = .data$mean + .data$sd
24-
),
25-
color = "darkgreen",
26-
linetype = "solid"
16+
dplyr::mutate(
17+
mean = mean(DATA_VALUE, na.rm = TRUE),
18+
sd = sd(DATA_VALUE, na.rm = TRUE)
19+
) |>
20+
ggplot2::ggplot(ggplot2::aes(x = YEAR, y = DATA_VALUE)) +
21+
ggplot2::geom_hline(
22+
ggplot2::aes(
23+
yintercept = .data$mean + .data$sd
24+
),
25+
color = "darkgreen",
26+
linetype = "solid"
2727
) +
28-
ggplot2::geom_hline(ggplot2::aes(
29-
yintercept = .data$mean - .data$sd
30-
),
31-
color = "darkgreen",
32-
linetype = "solid"
28+
ggplot2::geom_hline(
29+
ggplot2::aes(
30+
yintercept = .data$mean - .data$sd
31+
),
32+
color = "darkgreen",
33+
linetype = "solid"
3334
) +
34-
ggplot2::geom_hline(ggplot2::aes(
35-
yintercept = .data$mean
36-
),
37-
color = "darkgreen",
38-
linetype = "dotted"
35+
ggplot2::geom_hline(
36+
ggplot2::aes(
37+
yintercept = .data$mean
38+
),
39+
color = "darkgreen",
40+
linetype = "dotted"
3941
) +
4042
ggplot2::geom_point() +
4143
ggplot2::geom_line() +
4244
ggplot2::scale_y_continuous(labels = scales::comma) +
4345
# ecodata::theme_ts() +
4446
ggplot2::theme_classic(base_size = 16) +
45-
ggplot2::theme(strip.text = ggplot2::element_text(size = 16),
46-
axis.title = ggplot2::element_blank(),
47-
aspect.ratio = ar,
48-
plot.background = ggplot2::element_rect(fill='transparent',
49-
color='transparent'))
50-
51-
if(include_trends) {
47+
ggplot2::theme(
48+
strip.text = ggplot2::element_text(size = 16),
49+
axis.title = ggplot2::element_blank(),
50+
aspect.ratio = ar,
51+
plot.background = ggplot2::element_rect(
52+
fill = 'transparent',
53+
color = 'transparent'
54+
)
55+
)
56+
57+
if (include_trends) {
5258
plt <- plt +
5359
ecodata::geom_gls() +
5460
ecodata::geom_lm()
5561
}
56-
62+
5763
return(plt)
5864
}

0 commit comments

Comments
 (0)