Skip to content
Merged
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ Config/testthat/parallel: false
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.3.3
Config/roxygen2/version: 8.0.0
2 changes: 2 additions & 0 deletions R/add_theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' @param x table or figures object from ggplot, base r plot, gt table, flextable, or kable extra
#' @param discrete TRUE/FALSE indicate if data input is discrete. Specifically applied to plots.
#'
#' Default: TRUE
#'
#' @returns Add the standard formatting for stock assessment reports for any
#' figure or table.
#' @details Currently, the function is able to format objects from:
Expand Down
11 changes: 9 additions & 2 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
#' Format stock assessment output files to a standardized format.
#'
#' @param file Assessment model output file path
#' @param model Assessment model used in evaluation ("ss3", "bam",
#' "fims", "rceattle).
#' @param model Assessment model used in evaluation
#'
#' Default: NULL
#'
#' Options: "ss3", "bam", "fims", "rceattle"
#' @param fleet_names Names of fleets in the assessment model as
#' shortened in the output file. If fleet names are not properly read, then
#' indicate the fleets names as an acronym in a vector
#'
#' Default: NULL
#' @param save_dir File path to save the converted output file.
#'
#' Default: NULL
#'
#' @author Samantha Schiano
#'
Expand Down
2 changes: 2 additions & 0 deletions R/html_all_figs_tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param figures_tables_dir The location of the folder containing
#' figures and tables ("figures" and "tables").
#'
#' Default: The current working directory (`getwd()`)
#'
#' @returns A folder ("all_tables_figures") in your working directory containing
#' html and qmd files that show all tables and figures.
#'
Expand Down
30 changes: 24 additions & 6 deletions R/plot_abundance_at_age.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
#' Plot Abundance (or Numbers) at Age (AAA or NAA)
#'
#' @param dat A data frame returned from \link[stockplotr]{convert_output}
#' @param facet a string or vector of strings of column(s) that
#' groups the data (e.g. "fleet", "sex", "area", etc.). Set facet = "none" to
#' summarize the data in a single plot.
#' @param facet a string or vector of strings of a column that facets the data.
#' Set facet = "none" to summarize the data in a single plot.
#'
#' Default: NULL
#'
#' Options: Including, but not limited to: "year", "area", "fleet", "sex", "none",
#' NULL
#'
#' @param unit_label units for abundance
#'
#' Default: "fish"
#'
#' @param scale_amount A number describing how much to scale down the abundance at
#' age. Please choose a value ranging from 1-1,000,000,000 (one billion) in orders
#' of magnitude (e.g., 1, 10, 100, 1000, etc.). For example, scale_amount = 100
#' would scale down a value from 500,000 --> 5,000 and would report abundance in
#' hundreds of fish (if "fish" was the unit_label). This scale will be reflected
#' in the legend label if proportional is set to FALSE. The default is 1,000.
#' in the legend label if proportional is set to FALSE.
#'
#' Default: 1,000
#'
#' @param proportional Set size of points relative to z when TRUE, point
#' size are relative to one another while when set to FALSE, point size
#' is relative to z
#'
#' Default: `TRUE`
#'
#' @param make_rda TRUE/FALSE; indicate whether to produce an .rda file containing
#' a list with the figure/table, caption, and alternative text (if figure). If TRUE,
#' the .rda will be exported to the folder indicated in the argument "rda_dir".
#' Default is FALSE.
#'
#' Default: `FALSE`
#'
#' @param figures_dir The location of the folder containing the generated .rda files
#' ("rda_files") that will be created if the argument `make_rda` = TRUE.
#' Default is the working directory.
#'
#' Default: the working directory (`getwd()`)
#'
#' @returns A plot showing total abundance (or numbers) at age.
#'
#' @details The input is from an assessment model output file
Expand Down
17 changes: 11 additions & 6 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
#'
#' @inheritParams plot_spawning_biomass
#' @param unit_label units for biomass
#'
#' Default: "mt"
#' @param ref_line A string specifying the type of reference you want to
#' compare biomass to. The default is `"msy"`, which looks for
#' compare biomass to. The default `"msy"` looks for
#' `"biomass_msy"` in the `"label"` column of `dat`. The actual
#' searching in `dat` is case agnostic and will work with either upper- or
#' lower-case letters but you must use one of the options specified in the
#' searching in `dat` is case-agnostic and will work with either upper- or
#' lower-case letters. However, you must use one of the options specified in the
#' default list to ensure that the label on the figure looks correct
#' regardless of how it is specified in `dat`. Other possibilities may include
#' "target", "MSY", and "unfished".
#' regardless of how it is specified in `dat`.
#'
#' Default: "msy"
#'
#' Options: Including, but not limited to: "target", "MSY", "unfished"
#' @returns A plot showing total biomass.
#'
#' @details The input is from an assessment model output file
Expand Down Expand Up @@ -43,7 +48,7 @@ plot_biomass <- function(
facet = NULL,
ref_line = "msy",
era = NULL,
unit_label = "metric tons",
unit_label = "mt",
module = NULL,
scale_amount = 1,
relative = FALSE,
Expand Down
9 changes: 7 additions & 2 deletions R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
#' age. For example, scale_amount = 100 would scale down a value
#' from 500,000 --> 5,000. This scale will be reflected in the legend label if
#' proportion is set to FALSE.
#'
#' Default: 1,000
#'
#' @param interactive TRUE/FALSE; indicate whether the environment in which the
#' function is operating is interactive. This bypasses some options for
#' filtering when preparing data for the plot. Default is FALSE.
#' filtering when preparing data for the plot.
#'
#' Default: `TRUE`
#'
#' @returns A plot showing total biomass at age.
#'
Expand Down Expand Up @@ -40,7 +45,7 @@ plot_biomass_at_age <- function(
unit_label = "mt",
scale_amount = 1000,
proportional = TRUE,
interactive = FALSE,
interactive = TRUE,
make_rda = FALSE,
figures_dir = getwd()
) {
Expand Down
34 changes: 24 additions & 10 deletions R/plot_catch_comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@
#'
#' @inheritParams plot_abundance_at_age
#' @param unit_label indicate the name of the units of catch as to label the axis
#'
#' Default: "mt"
#'
#' @param scale_amount A number describing how much to scale down the catch at
#' age. Please choose a value ranging from 1-1,000,000,000 (one billion) in orders
#' of magnitude (e.g., 1, 10, 100, 1000, etc.). For example, scale_amount = 100
#' would scale down a value from 500,000 --> 5,000 and would report catch in
#' hundreds of the 'unit_label'. This scale will be reflected
#' in the legend label if proportional is set to FALSE. The default is 1.
#' @param era a string naming the era of data such as historical ("early"), current ("time"), or
#' projected ("fore") data if filtering should occur. Default is set to "time" which is
#' the current time. To plot all data, set era to NULL.
#' @param interactive TRUE/FALSE; indicate whether the environment in which the
#' function is operating is interactive. This bypasses some options for
#' filtering when preparing data for the plot. Default is FALSE.
#' @param module (Optional) A string indicating the linked module_name associated
#' with the label for the plot if known. Default is NULL. By default, the function
#' will select the most relevant module if more than 1 exists.
#' in the legend label if proportional is set to FALSE.
#'
#' Default: 1
#'
#' @param era A string naming the era of data.
#'
#' Default: "time"
#'
#' Options: "early", "time", "fore" (forecast), or NULL (all data)
#'
#' @param interactive A logical value indicating if the environment is interactive.
#'
#' Default: `FALSE`
#'
#' @param module (Optional) A string indicating the module_name found in `dat`.
#' If selecting >1 module, place them in a vector like c("module1", "module2").
#'
#' Default: NULL
#'
#' If the interactive and >1 module_name is found, user will select the
#' module_name in the console. @seealso [filter_data()]
#'
#' @returns A plot showing catch or landings composition.
#'
#' @details This plot is made only when catch or landings are explicitly named
Expand Down
10 changes: 8 additions & 2 deletions R/plot_indices.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#' Plot Index of Abundance
#'
#' @inheritParams plot_spawning_biomass
#' @param facet a string or vector of strings of a column that facets the data
#' (e.g. "year", "area", etc.) "fleet" is always added on to any faceting selections
#' @param facet a string or vector of strings of a column that facets the data. "fleet" is always added on to any faceting selections
#'
#' Default: NULL
#'
#' Options: May include, but is not limited to: "fleet", "year", "area", NULL
#' @param unit_label units for index of abundance/CPUE
#'
#' Default: ""
#' @param focus a string or vector of strings indicating how data should be
#' filtered. (i.e. select names of fleets to zoom into the plot)
#'
#' Default: NULL
#' @returns A plot showing the expected and predicted indices.
#'
#' @details The input is from an assessment model output file
Expand Down
2 changes: 1 addition & 1 deletion R/plot_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' )
plot_landings <- function(
dat,
unit_label = "metric tons",
unit_label = "mt",
geom = "line",
group = NULL,
facet = NULL,
Expand Down
2 changes: 2 additions & 0 deletions R/plot_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' @inheritParams plot_spawning_biomass
#' @param unit_label units for recruitment
#'
#' Default: "mt"
#'
#' @returns A plot showing recruitment over time.
#'
#' @details The input is from an assessment model output file
Expand Down
12 changes: 7 additions & 5 deletions R/plot_spawning_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#' Default: "line".
#'
#' Options: "line", "point", or "area"
#' @param group A string of a single column that groups the data (e.g. "fleet",
#' "sex", "area", etc.).
#' @param group A string of a single column that groups the data.
#'
#' Set group = "none" to summarize data over all indexing values.
#'
#' Default: NULL
#' Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL
#'
#' @param facet A string or vector of strings of a column name.
#'
#' Default: NULL
Expand All @@ -35,13 +36,14 @@
#' If the reference point is not found in the data, set ref_line = c("name" = value).
#' @param unit_label A string specifying spawning biomass unit.
#'
#' Default: "metric tons"
#' Default: "mt"
#' @param lbs A logical value indicating whether to convert the y-axis values from
#' kilograms to pounds. The default units match the default in the
#' unit_label argument - 'metric tons'.
#' unit_label argument - 'mt'.
#'
#' Default: `FALSE`
#' @param module (Optional) A string indicating the module_name found in `dat`.
#' If selecting >1 module, place them in a vector like c("module1", "module2").
#'
#' Default: NULL
#'
Expand Down Expand Up @@ -107,7 +109,7 @@ plot_spawning_biomass <- function(
group = NULL,
facet = NULL,
ref_line = "msy",
unit_label = "metric tons",
unit_label = "mt",
era = NULL,
lbs = FALSE,
module = NULL,
Expand Down
8 changes: 8 additions & 0 deletions R/plot_stock_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
#' plot is being made in is interactive. By default, this
#' is set to false. If true, dependent on your data, a
#' option menu will pop-up.
#'
#' Default: TRUE
#'
#' @param spawning_biomass_label Units for spawning biomass
#'
#' Default: "mt"
#'
#' @param recruitment_label units for recruitment
#'
#' Default: "mt"
#'
#' @returns A plot showing the stock recruitment relationship.
#'
#' @details The input is from an assessment model output file
Expand Down
22 changes: 18 additions & 4 deletions R/process_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@
#'
#' @param dat Pre-filtered data from \link[stockplotr]{filter_data} following a
#' long format data.
#' @param group A string identifying the indexing variable of the data. If you
#' want to just summarize the data across all factors, set group = "none".
#' @param group A string identifying the indexing variable of the data.
#' To remove any groups and summarize data across all factors, set
#' group = "none". Setting group = NULL will keep any grouping
#' variables identified in the data by the function.
#'
#' Default: NULL
#'
#' Options: Including, but not limited to: "year", "area", "fleet", "sex", "none", NULL
#' @param facet A string or vector of strings identifying the faceting
#' variable(s) of the data.
#'
#' Default: NULL
#' @param lbs A logical value indicating whether to convert the y-axis values from
#' kilograms to pounds. The default units match the default in the
#' unit_label argument - 'metric tons'.
#'
#' Default: `FALSE`
#' @param method A string describing the method of summarizing data when group
#' is set to "none". Options are "sum" or "mean". Default is "sum".
#' is set to "none".
#'
#' Default: "sum"
#'
#' Options: "sum" or "mean"
#'
#' @returns List of 3 objects:
#' \item{data}{A data frame of the processed data ready for plotting.}
Expand Down Expand Up @@ -360,6 +372,8 @@ process_data <- function(
#'
#' @inheritParams process_data
#' @param label A string or vector of strings identifying the label values to filter the data.
#'
#' Default: NULL
#'
#' @returns A dataframe of processed data ready for formatting into a table.
#' @details Input is an object created with \link[stockplotr]{filter_data}.
Expand All @@ -369,7 +383,7 @@ process_data <- function(
#' @examples {
#' filtered <- filter_data(
#' dat = stockplotr:::example_data,
#' label_name = "landings",
#' label = "landings",
#' geom = "line",
#' era = "time"
#' )
Expand Down
Loading
Loading