Skip to content

Commit

Permalink
Adjustments to package for better practice
Browse files Browse the repository at this point in the history
  • Loading branch information
Schiano-NOAA committed Jul 31, 2024
1 parent 0048b37 commit 4e4f290
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 0.1.0
Author: Samantha Schiano, Bai Li, Steve Saul, Kelli F. Johnson, & Megumi Oshima
Maintainer: Samantha Schiano <samantha.schiano@noaa.gov>
Description: Creates exploratory and finished tables and figures for stock assessment
documents from U.S. stock assessment model outputs. This packages addresses
documents from U.S. stock assessment model outputs. This packages addresses
parts of the stock assessment workflow that interprets outputs of stock
assessment models as well as allows the analyst to create report ready tables
and figures, reducing the need to create their own and format then when adding
Expand All @@ -21,12 +21,11 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
Imports:
cowplot,
dplyr,
extrafont,
flextable,
ggplot2,
naniar,
stats,
stringr,
tidyr,
utils
7 changes: 6 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

export(add_theme)
export(plot_recruitment)
export(plot_spawning_biomass)
export(table_indices)
11 changes: 6 additions & 5 deletions R/plot_land.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
plot_land <- function(dat){
output <- dat |> filter(label == "landings")
plot_land <- function(dat,
model){
output <- dat |> dplyr::filter(label == "landings")

narea <- length(unique(output$area))
nseas <- length(unique(output$season))

if (narea > 1 | nseas > 1) {

} else {
plt <- ggplot(data = output) +
geom_line(aes(x = time, y = label))+
facet_wrap(~fleet)
plt <- ggplot2::ggplot(data = output) +
ggplot2::geom_line(ggplot2::aes(x = time, y = label))+
ggplot2::facet_wrap(~fleet)
}
add_theme(plt)
}
8 changes: 7 additions & 1 deletion R/ss3_utils.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Utility functions to read and support SS3
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

# Before converted development

SS3_extract_df <- function(dat, label){
# Read SS3 report file

Expand Down Expand Up @@ -41,7 +47,7 @@ SS3_extract_bio_info <- function(
return(nummax)
}

output <- read.table(
output <- utils::read.table(
file = dat, col.names = 1:get_ncol(dat), fill = TRUE, quote = "",
colClasses = "character", nrows = -1, comment.char = "",
blank.lines.skip = FALSE
Expand Down
4 changes: 2 additions & 2 deletions R/table_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ table_indices <- function(dat,
indices <- merge(index2_obs, index2_se) |>
dplyr::rename(year = Yr)
indices <- indices[, sort(names(indices))] |>
dplyr::select("year", everything())
dplyr::select("year", dplyr::everything())
indices[is.na(indices)] <- "-"

tab <- indices |>
Expand All @@ -88,7 +88,7 @@ table_indices <- function(dat,
if(model == "BAM"){
output <- dget(dat)
indices <- output$t.series |>
dplyr::select(year, contains("U.") & contains(".ob") | contains("cv.U"))
dplyr::select(year, dplyr::contains("U.") & contains(".ob") | contains("cv.U"))

# Create function to reorder column names so ordered by fleet
fleet_names <- function(x){
Expand Down
8 changes: 6 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
# Things to load on start up
.onLoad <- function(libname, pkgname){
# import NOAA approved fonts from package
extrafont::loadfonts()
suppressPackageStartupMessages(
extrafont::loadfonts()
)
suppressWarnings(
extrafont::font_import(pattern = c("cambria", "arial"), prompt = FALSE)
suppressMessages(
extrafont::font_import(pattern = c("cambria", "arial"), prompt = FALSE)
)
)

}

0 comments on commit 4e4f290

Please sign in to comment.