diff --git a/R/convert_output.R b/R/convert_output.R index 218d782e..d1559229 100644 --- a/R/convert_output.R +++ b/R/convert_output.R @@ -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 @@ -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). #' @@ -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 @@ -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 #### @@ -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) diff --git a/R/create_title.R b/R/create_title.R index e8650b6c..d1b77cb2 100644 --- a/R/create_title.R +++ b/R/create_title.R @@ -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)) { diff --git a/man/convert_output.Rd b/man/convert_output.Rd index 3ce93d26..05e9dd31 100644 --- a/man/convert_output.Rd +++ b/man/convert_output.Rd @@ -6,11 +6,11 @@ \usage{ convert_output( output_file = NULL, - outdir = NULL, + outdir = getwd(), model = NULL, fleet_names = NULL, file_save = FALSE, - savedir = NULL, + savedir = getwd(), save_name = "std_model_output" ) } @@ -18,7 +18,8 @@ convert_output( \item{output_file}{Assessment model output file (e.g., the Report.sso file for SS3, the rdat file for BAM, etc.)} -\item{outdir}{Directory of the assessment model output file.} +\item{outdir}{Directory of the assessment model output file. Defaults to +working directory.} \item{model}{Assessment model used in evaluation ("ss3", "bam", "asap", "fims", "amak", "ms-java", "wham", "mas").} @@ -31,7 +32,8 @@ indicate the fleets names as an acronym in a vector} than calling the function and adding the formatted object to the global environment? Default is false.} -\item{savedir}{Directory to save the converted output file.} +\item{savedir}{Directory to save the converted output file. Defaults to +working directory.} \item{save_name}{Name of the converted output file (do not use spaces).}