Skip to content

Commit

Permalink
Add minor change to convert_output arg defaults and format latin name…
Browse files Browse the repository at this point in the history
… in title (#88)

* update(convert_output): change dir args to wd

*Specific output data file columns set to numeric

* update(create_title): improve formatting in title - make latin name italicized

* Update(documentation): for convert_output changes to args
  • Loading branch information
Schiano-NOAA authored Nov 26, 2024
1 parent b74f346 commit 452b1c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
29 changes: 16 additions & 13 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#'
#' @param output_file Assessment model output file (e.g., the
#' Report.sso file for SS3, the rdat file for BAM, etc.)
#' @param outdir Directory of the assessment model output file.
#' @param outdir Directory of the assessment model output file. Defaults to
#' working directory.
#' @param model Assessment model used in evaluation ("ss3", "bam",
#' "asap", "fims", "amak", "ms-java", "wham", "mas").
#' @param fleet_names Names of fleets in the assessment model as
Expand All @@ -13,7 +14,8 @@
#' @param file_save TRUE/FALSE; Save the formatted object rather
#' than calling the function and adding the formatted object to
#' the global environment? Default is false.
#' @param savedir Directory to save the converted output file.
#' @param savedir Directory to save the converted output file. Defaults to
#' working directory.
#' @param save_name Name of the converted output file (do not use
#' spaces).
#'
Expand All @@ -32,11 +34,11 @@
#'
convert_output <- function(
output_file = NULL,
outdir = NULL,
outdir = getwd(),
model = NULL,
fleet_names = NULL,
file_save = FALSE,
savedir = NULL,
savedir = getwd(),
save_name = "std_model_output") {
#### out_new ####
# Blank dataframe and set up to mold output into
Expand Down Expand Up @@ -80,15 +82,15 @@ convert_output <- function(
out_new <- out_new[-1, ]

# pull together path
if (!is.null(outdir)) {
output_file <- paste(outdir, "/", output_file, sep = "")
} else {
if(file.exists(output_file)) {
output_file <- output_file
} else {
output_file <- file.path(outdir, output_file)
}

# Check if can locate output file
# check path
if (!file.exists(output_file)) {
stop("output file path is invalid.")
stop("File not found.")
}

#### SS3 ####
Expand Down Expand Up @@ -1164,10 +1166,11 @@ convert_output <- function(

#### Exporting ####
# Combind DFs into one
out_new <- Reduce(rbind, out_list) # |>
# dplyr::mutate(estimate = as.numeric(estimate),
# uncertainty = as.numeric(uncertainty),
# initial = as.numeric(initial))
out_new <- Reduce(rbind, out_list) |>
dplyr::mutate(estimate = as.numeric(estimate),
uncertainty = as.numeric(uncertainty),
initial = as.numeric(initial)) |>
suppressWarnings()
if (tolower(model) == "ss3") {
con_file <- system.file("resources", "ss3_var_names.xlsx", package = "asar", mustWork = TRUE)
var_names_sheet <- openxlsx::read.xlsx(con_file)
Expand Down
3 changes: 3 additions & 0 deletions R/create_title.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ create_title <- function(
year <- format(Sys.Date(), "%Y")
}

# Species latin name with italics latex fxn
spp_latin <- paste("\\textit{", spp_latin, "}", sep = "")

# Create title dependent on regional language
if (office == "AFSC") {
if (is.null(complex)) {
Expand Down
10 changes: 6 additions & 4 deletions man/convert_output.Rd

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

0 comments on commit 452b1c9

Please sign in to comment.