From f1c8ad83bb03158a2a7e98b2e73ba9d947f0a9d9 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 23 Jan 2025 15:06:35 -0500 Subject: [PATCH] re-removed export_rda and extract_caps_alttext from utils R script (error with rebasing?) --- R/utils.R | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/R/utils.R b/R/utils.R index 23bad4b..5a54d0b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -2,61 +2,6 @@ # General utility functions #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - - - - # extract plot or table's caption and alt text - cap <- captions_alttext_df |> - dplyr::filter(label == topic_label, - type == fig_or_table) |> - dplyr::select(caption) |> - as.character() - - if (fig_or_table == "figure"){ - alt_text <- captions_alttext_df |> - dplyr::filter(label == topic_label, - type == "figure") |> - dplyr::select(alt_text) |> - as.character() - - caps_alttext_list <- list(cap, - alt_text) - } else { - caps_alttext_list <- list(cap) - } - - return(caps_alttext_list) -} - -# export ggplot, alt text, and caption to rda if indicated in arguments -export_rda <- function(final = final, - caps_alttext = caps_alttext, - rda_dir = rda_dir, - topic_label = topic_label, - fig_or_table = fig_or_table){ - - # make rda for figures - if (fig_or_table == "figure") { - rda <- list("figure" = final, - "cap" = caps_alttext[[1]], - "alt_text" = caps_alttext[[2]]) - # make rda for tables - } else if (fig_or_table == "table"){ - rda <- list("table" = final, - "cap" = caps_alttext[[1]]) - } - - # check if an rda_files folder already exists; if not, make one - if (!dir.exists(fs::path(rda_dir, "rda_files"))) { - dir.create(fs::path(rda_dir, "rda_files")) - } - - save(rda, - file = fs::path(rda_dir, - "rda_files", - paste0(topic_label, "_", fig_or_table, ".rda"))) -} - # substitute in more key quantities (units, end_years, reference points) to captions/alt text add_more_key_quants <- function( topic = topic_label,