Skip to content

Commit

Permalink
re-removed export_rda and extract_caps_alttext from utils R script (e…
Browse files Browse the repository at this point in the history
…rror with rebasing?)
  • Loading branch information
sbreitbart-NOAA committed Jan 23, 2025
1 parent 1805490 commit f1c8ad8
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f1c8ad8

Please sign in to comment.