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
Schiano-NOAA authored Dec 11, 2024
1 parent d599476 commit 06941a9
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 143 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ Suggests:
VignetteBuilder:
knitr
Remotes:
nmfs-fish-tools/nmfspalette,
nmfs-fish-tools/nmfspalette,
nmfs-ost/satf,
r4ss/r4ss,
nmfs-fish-tools/nmfspalette
r4ss/r4ss
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
LazyData: true
2 changes: 1 addition & 1 deletion R/add_chunk.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_chunk <- function(
chunk_op = NULL,
rmark_op = NULL) {
chunk <- paste0(
"```{r", ifelse(add_option, paste0(c("",rmark_op), collapse = ", "), ""), "} \n"
"```{r", ifelse(add_option, paste0(c("", rmark_op), collapse = ", "), ""), "} \n"
)
if (!is.null(label)) {
chunk <- paste0(
Expand Down
12 changes: 7 additions & 5 deletions R/asar-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
NULL

## quiets concerns of R CMD check re: the .'s that appear in pipelines
globvar <- c("yr","value","estimate","seas","subseas","age_bins","morph",
"age","year","nsim","fleet","uncertainty","initial","alt_label",
"last","affiliation","label","type","caption","alt_text","caption",
"name",".")
if(getRversion() >= "2.15.1") utils::globalVariables(globvar)
globvar <- c(
"yr", "value", "estimate", "seas", "subseas", "age_bins", "morph",
"age", "year", "nsim", "fleet", "uncertainty", "initial", "alt_label",
"last", "affiliation", "label", "type", "caption", "alt_text", "caption",
"name", "."
)
if (getRversion() >= "2.15.1") utils::globalVariables(globvar)
8 changes: 4 additions & 4 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ convert_output <- function(
# Extract names from landings
landings <- dat$t.series |>
dplyr::select(dplyr::contains("L.") & dplyr::contains(".ob") |
dplyr::contains("D.") & dplyr::contains(".ob"))
dplyr::contains("D.") & dplyr::contains(".ob"))
fleets_land <- stringr::str_extract(as.vector(colnames(landings)), "(?<=L\\.)\\w+(?=\\.ob)")
fleets_disc <- stringr::str_extract(as.vector(colnames(landings)), "(?<=D\\.)\\w+(?=\\.ob)")
# Extract names from lof F dev
parm <- dat$parm.tvec |>
dplyr::select(dplyr::contains("log.F.dev.")|
dplyr::contains("log.F.dev.") & dplyr::contains(".D"))
dplyr::select(dplyr::contains("log.F.dev.") |
dplyr::contains("log.F.dev.") & dplyr::contains(".D"))
# fleets_parm_D <- stringr::str_extract(as.vector(colnames(parm)), "(?<=log\\.F\\.dev\\.)\\w+(?=\\.D)")
fleets_parm <- stringr::str_extract(as.vector(colnames(parm)), "(?<=log\\.F\\.dev\\.)\\w+")
fleets <- unique(c(fleets_ind, fleets_land, fleets_disc, fleets_parm))
Expand Down Expand Up @@ -1183,7 +1183,7 @@ convert_output <- function(
var_names_sheet <- openxlsx::read.xlsx(con_file)
}
if (file.exists(con_file)) {
out_new <- dplyr::inner_join(out_new, var_names_sheet, by = c("module_name","label")) |>
out_new <- dplyr::inner_join(out_new, var_names_sheet, by = c("module_name", "label")) |>
dplyr::mutate(label = dplyr::case_when(
!is.na(alt_label) ~ alt_label,
TRUE ~ label
Expand Down
7 changes: 2 additions & 5 deletions R/create_figures_doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ create_figures_doc <- function(resdir = NULL,
subdir = NULL,
include_all = TRUE,
rda_dir = NULL) {

model <- match.arg(model, several.ok = FALSE)

if (include_all) {

# add header
figures_doc <- paste0("## Figures \n \n")

# add chunk that creates object as the directory of all rdas
figures_doc <- paste0(
figures_doc <- paste0(
figures_doc,
add_chunk(
paste0("rda_dir <- '", rda_dir, "/rda_files'"),
label = "set-rda-dir-figs",
eval = "true"
),
),
"\n"
)

Expand Down Expand Up @@ -283,7 +281,6 @@ spawning_recruitment_alt_text <- spawning_recruitment_plot_rda$alt_text"),
),
"\n"
)

} else {
# add option for only adding specified figures
}
Expand Down
5 changes: 1 addition & 4 deletions R/create_tables_doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ create_tables_doc <- function(resdir = NULL,
subdir = NULL,
include_all = TRUE,
rda_dir = NULL) {

model <- match.arg(model, several.ok = FALSE)

if (include_all) {

# add header
tables_doc <- paste0("## Tables \n \n")

Expand All @@ -32,7 +30,7 @@ create_tables_doc <- function(resdir = NULL,
paste0("rda_dir <- '", rda_dir, "/rda_files'"),
label = "set-rda-dir-tbls",
eval = "false"
),
),
"\n"
)

Expand Down Expand Up @@ -74,7 +72,6 @@ indices_cap <- indices_table_rda$cap"),
)

# Add other tables follow the same above format

} else {
# add option for only adding specified tables
}
Expand Down
Loading

0 comments on commit 06941a9

Please sign in to comment.