From ceb778e9be937fd3511738d40922f1fbb78b0965 Mon Sep 17 00:00:00 2001 From: "Joseph Caracappa (NOAA)" <57966543+jcaracappa1@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:48:30 -0500 Subject: [PATCH] remove old data and functions --- R/plot_thermal_habitiat_area_annual.R | 68 ---------------------- data-raw/get_thermal_habitat_area_annual.R | 21 ------- 2 files changed, 89 deletions(-) delete mode 100644 R/plot_thermal_habitiat_area_annual.R delete mode 100644 data-raw/get_thermal_habitat_area_annual.R diff --git a/R/plot_thermal_habitiat_area_annual.R b/R/plot_thermal_habitiat_area_annual.R deleted file mode 100644 index 1030681f..00000000 --- a/R/plot_thermal_habitiat_area_annual.R +++ /dev/null @@ -1,68 +0,0 @@ -#' plot thermal habitat area -#' -#' plots thermal_habitat_area data set. -#' -#' @param shadedRegion Numeric vector. Years denoting the shaded region of the plot (most recent 10) -#' @param report Character string. Which SOE report ("MidAtlantic", "NewEngland") -#' @param EPU Character string. Which EPU for New England report ("GB", "GOM") Mid will always be MAB -#' -#' @return ggplot object -#' -#' @export - -#' - -plot_thermal_habitat_area_annual <- function(shadedRegion = NULL, - report="MidAtlantic", - EPU = "MAB") { - - # generate plot setup list (same for all plot functions) - setup <- ecodata::plot_setup(shadedRegion = shadedRegion, - report=report) - - # which report? this may be bypassed for some figures - if (report == "MidAtlantic") { - filterEPUs <- c("MAB") - } else { - if (!(EPU %in% c("GB","GOM"))) { - stop("For NewEngland the epu must be either 'GB' or 'GOM'") - } - filterEPUs <- EPU - } - - # optional code to wrangle ecodata object prior to plotting - # e.g., calculate mean, max or other needed values to join below - - - fix <- ecodata::thermal_habitat_area_annual |> - dplyr::filter(EPU == filterEPUs) - - limits <- fix |> - dplyr::group_by(Var,Time) |> - dplyr::summarise(areaMinProportion = min(Value), - areaMaxProportion = max(Value), - .groups = "drop") - - fix <- fix |> - dplyr::left_join(limits,by=c("Var","Time")) - - fix.this.year = fix |> - dplyr::filter(Time == max(Time)) |> - dplyr::mutate(ReportYear = max(Time)) - - p <- ggplot2::ggplot()+ - # ggplot2::geom_line(data=fix, ggplot2::aes(x = temp.threshold, ymin = areaMinProportion, ymax = areaMaxProportion))+ - ggplot2::geom_line(data=fix,ggplot2::aes(x = temp.threshold, y= Value,group = Time,color = Time),alpha = 0.7,size =1.2)+ - ggplot2::scale_color_gradient(name = "Year",low = 'grey70',high ='blue2')+ - ggplot2::geom_line(data=dplyr::filter(fix.this.year,Time == max(Time)),ggplot2::aes(x = temp.threshold, y = Value, linetype = as.factor(ReportYear)), color = 'black',alpha = 0.7,size =2)+ - ggplot2::scale_linetype_manual(name = 'Report Year',values = 1)+ - ggplot2::theme_bw()+ - ggplot2::xlab('Temperature Threshold (\u00B0C)')+ - ggplot2::ylab('Proportion of EPU Area above threshold') + - ggplot2::ggtitle(filterEPUs)+ - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5)) - - - return(p) - -} diff --git a/data-raw/get_thermal_habitat_area_annual.R b/data-raw/get_thermal_habitat_area_annual.R deleted file mode 100644 index 1e276465..00000000 --- a/data-raw/get_thermal_habitat_area_annual.R +++ /dev/null @@ -1,21 +0,0 @@ -### Thermal Habitat Area - Joe Caracappa - -# library(dplyr) -# library(usethis) - -get_thermal_habitat_area_annual <- function(save_clean = F){ - - thermal_habitat_area_annual<-readr::read_csv(here::here("data-raw/thermal_threshold_annual_area_SOE2025.csv"), - show_col_types = F) |> - dplyr::relocate(Time,EPU,Var,Value,Source) - - if (save_clean){ - usethis::use_data(thermal_habitat_area_annual, overwrite = T) - } else { - return(thermal_habitat_area_annual) - } -} -get_thermal_habitat_area_annual(save_clean = T) - - -