Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: stockplotr
Title: Tables and Figures for Stock Assessments
Version: 0.11.0
Version: 0.12.0
Authors@R: c(
person("Samantha", "Schiano", , "samantha.schiano@noaa.gov", role = c("aut", "cre"),
comment = c(ORCID = "0009-0003-3744-6428")),
Expand Down
18 changes: 15 additions & 3 deletions R/table_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#' want to just summarize the data across all factors, set group = "none".
#' @param method A string describing the method of summarizing data when group
#' is set to "none". Options are "sum" or "mean". Default is "sum".
#' @param digits Numeric value indicating the number of rounding digits.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @param digits Numeric value indicating the number of rounding digits.
#' @param digits Numeric value indicating the number of rounding digits. Trailing zeroes will not be added to the estimate (example: rounding 0.1 to 4 digits will still produce 0.1).

This doesn't add trailing zeroes if the number doesn't have them (example: round(as.numeric(5.5), digits = 4) will still produce 5.5. I suggest noting that here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a arg in round to still show trailing zeros. I am going to look into it before I merge this suggestion.

#'
#' Default: 2
#' @param tables_dir The location of the folder containing the generated table
#' rda files ("tables") that will be created if the argument `make_rda` = TRUE.
#' @param label The label that will be chosen from the input file. If unspecified,
Expand Down Expand Up @@ -40,9 +43,18 @@ table_landings <- function(
method = "sum",
module = NULL,
label = NULL,
digits = 2,
scale_amount = 1,
make_rda = FALSE,
tables_dir = getwd()
) {
# set unit label if scaled
unit_label <- label_magnitude(
label = "",
unit_label = unit_label,
scale_amount = scale_amount
)

# TODO: do group and facet need to be uncommented and updated?
# Filter data for landings
prepared_data <- filter_data(
Expand All @@ -51,11 +63,11 @@ table_landings <- function(
geom = "line",
era = era,
module = module,
scale_amount = 1,
scale_amount = scale_amount,
interactive = interactive
) |>
dplyr::mutate(estimate = round(as.numeric(estimate), digits = 0)) |>
dplyr::mutate(uncertainty = round(as.numeric(uncertainty), digits = 2))
dplyr::mutate(estimate = round(as.numeric(estimate), digits = digits)) |>
dplyr::mutate(uncertainty = round(as.numeric(uncertainty), digits = digits))

# Add check if there is any data
if (nrow(prepared_data) == 0) {
Expand Down
8 changes: 4 additions & 4 deletions R/utils_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ merge_error <- function(table_data, uncert_lab, fleets, label, unit_label) {
label_cols_final <- c(
ifelse(
id_uncert == "uncertainty",
paste0(stringr::str_to_title(label), " (", unit_label, ")"),
paste0(stringr::str_to_title(label), " (", unit_label, ") (", id_uncert, ")")
paste0(stringr::str_to_title(label), " ", unit_label),
paste0(stringr::str_to_title(label), " ", unit_label, " (", id_uncert, ")")
),
id_uncert
)
Expand All @@ -235,10 +235,10 @@ merge_error <- function(table_data, uncert_lab, fleets, label, unit_label) {
uncert_lab, " ", label_lab
)
if (uncert_lab == "uncertainty" || length(uncert_lab) == 0) {
label_cols_final <- c(paste0(label_lab, " (", unit_label, ")"), uncert_lab)
label_cols_final <- c(paste0(label_lab, " ", unit_label), uncert_lab)
} else {
label_cols_final <- c(
paste0(label_lab, " (", unit_label, ") (", uncert_lab, ")"),
paste0(label_lab, " ", unit_label, " (", uncert_lab, ")"),
id_uncert_col
)
}
Expand Down
10 changes: 10 additions & 0 deletions man/table_landings.Rd

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

Loading