Skip to content

Commit

Permalink
Merge pull request #86 from ldecicco-USGS/main
Browse files Browse the repository at this point in the history
weekly colors
  • Loading branch information
ldecicco-USGS authored Apr 29, 2024
2 parents 7c8b887 + 394dd59 commit 81c7fb8
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ BuildVignettes: true
LazyLoad: yes
LazyData: yes
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
27 changes: 21 additions & 6 deletions R/frequency_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ weekly_frequency_table <- function(gw_level_dv,
#' @param y_axis_label the label used for the y-axis of the plot.
#' @param flip logical. If \code{TRUE}, flips the y axis so that the smallest number is on top.
#' Default is \code{FALSE}.
#' @param percentile_colors Optional argument to provide a vector of 5 colors
#' used to fill the percentile bars in order from lowest percentile bin to the
#' highest percentile bin. Default behavior (NA) is to use legacy plot colors.
#' @return a ggplot object with rectangles representing the historical weekly percentiles,
#' and points representing the historical median and daily values
#'
Expand Down Expand Up @@ -716,7 +719,8 @@ weekly_frequency_plot <- function(gw_level_dv,
plot_title = "",
subtitle = "U.S. Geological Survey",
y_axis_label = "",
flip = FALSE) {
flip = FALSE,
percentile_colors = NA) {

data_list <- set_up_data(gw_level_dv = gw_level_dv,
gwl_data = gwl_data,
Expand Down Expand Up @@ -818,11 +822,22 @@ weekly_frequency_plot <- function(gw_level_dv,
ordered = TRUE))

# Assign colors and shapes
rectangle_colors <- c("5 - 10" = "palevioletred2",
"10 - 25" = "rosybrown1",
"25 - 75" = "darkolivegreen1",
"75 - 90" = "lightskyblue2",
"90 - 95" = "skyblue3")
groups <- c("5 - 10", "10 - 25", "25 - 75", "75 - 90", "90 - 95")
color_list <- c("palevioletred2", "rosybrown1", "darkolivegreen1", "lightskyblue2",
"skyblue3")

if (length(percentile_colors) >= 5) {
color_list <- percentile_colors
}
else if (is.na(percentile_colors) == FALSE) {
warning(paste0("percentile_colors argument was provided but was invalid,",
" should be a vector of length 5 in which each item in",
" the vector represents a color."))
}

rectangle_colors <- c(`5 - 10` = color_list[1], `10 - 25` = color_list[2],
`25 - 75` = color_list[3], `75 - 90` = color_list[4],
`90 - 95` = color_list[5])
point_shapes <- c("Historical weekly median" = 17,
"Provisional daily value" = 16,
"Approved daily value" = 16)
Expand Down
7 changes: 4 additions & 3 deletions R/included_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ NULL
.onAttach <- function(libname, pkgname) {
packageStartupMessage(
paste(strwrap('More information:
https://rconnect.usgs.gov/HASP_docs/', width = 40),
https://doi-usgs.github.io/HASP/', width = 40),
collapse='\n'))
}

Expand All @@ -141,8 +141,9 @@ https://rconnect.usgs.gov/HASP_docs/', width = 40),
#'
#' @name HASP-package
#' @docType package
#' @keywords Groundwater levels
NULL
#' @keywords internal
"_PACKAGE"


utils::globalVariables(c("lev_dt", "nYears","minMed", "maxMed", "name", "value",
"group", "plot_month_med", "p50", "sl_lev_va", "plot_month_last",
Expand Down
8 changes: 8 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ knitr::opts_chunk$set(echo = TRUE,
[![R build status](https://code.usgs.gov/water/stats/hasp/badges/main/pipeline.svg)](https://code.usgs.gov/water/stats/hasp/pipelines)
[![status](https://img.shields.io/badge/USGS-Documentation-blue.svg)](https://rconnect.usgs.gov/HASP_docs/)
[![status](https://img.shields.io/badge/USGS-Source-orange.svg)](https://code.usgs.gov/water/stats/hasp)
[![status](https://img.shields.io/badge/Release-Full-blue.svg)](https://code.usgs.gov/water/stats/hasp/-/tree/1.0.0)

*H*ydrologic *A*naly*S*is *P*ackage

Expand Down Expand Up @@ -163,6 +164,13 @@ plot_composite_data(aquifer_data, num_years)
plot_normalized_data(aquifer_data, num_years)
```

## Citing HASP


```{r cite}
citation(package = "HASP")
```


## Installation of R and RStudio

Expand Down
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
status](https://code.usgs.gov/water/stats/hasp/badges/main/pipeline.svg)](https://code.usgs.gov/water/stats/hasp/pipelines)
[![status](https://img.shields.io/badge/USGS-Documentation-blue.svg)](https://rconnect.usgs.gov/HASP_docs/)
[![status](https://img.shields.io/badge/USGS-Source-orange.svg)](https://code.usgs.gov/water/stats/hasp)
[![status](https://img.shields.io/badge/Release-Full-blue.svg)](https://code.usgs.gov/water/stats/hasp/-/tree/1.0.0)

*H*ydrologic *A*naly*S*is *P*ackage

Expand Down Expand Up @@ -182,6 +183,31 @@ plot_normalized_data(aquifer_data, num_years)

![](man/figures/README-example-2.png)<!-- -->

## Citing HASP

``` r
citation(package = "HASP")
#> To cite HASP in publications, please use:
#>
#> DeCicco, L.A., Prinos, S.T., Eslick-Huff, P.J., Hopkins, C.B., 2022,
#> HASP: Hydrologic AnalySis Package, v1.0.0.,
#> https://code.usgs.gov/water/stats/hasp, doi:10.5066/P9BUN5GV
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> author = {Laura DeCicco and Scott Prinos and Patrick Eslick-Huff and Candice Hopkins and Tara Root},
#> title = {HASP: Hydrologic AnalySis Package},
#> publisher = {U.S. Geological Survey},
#> address = {Reston, VA},
#> version = {1.0.0},
#> institution = {U.S. Geological Survey},
#> year = {2022},
#> doi = {10.5066/P9BUN5GV},
#> url = {https://code.usgs.gov/water/stats/hasp},
#> }
```

## Installation of R and RStudio

To use the HASP package, you will need to have R and RStudio installed
Expand All @@ -193,10 +219,9 @@ Instructions](https://owi.usgs.gov/R/training-curriculum/installr/)

Useful links:

- [Download R Windows](https://cran.r-project.org/bin/windows/base/)
- [Download R Mac](https://cran.r-project.org/bin/macosx/)
- [Download
RStudio](https://www.rstudio.com/products/rstudio/download/)
- [Download R Windows](https://cran.r-project.org/bin/windows/base/)
- [Download R Mac](https://cran.r-project.org/bin/macosx/)
- [Download RStudio](https://www.rstudio.com/products/rstudio/download/)

## Running the apps

Expand Down
28 changes: 26 additions & 2 deletions man/HASP-package.Rd

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

Binary file modified man/figures/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-graphs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-graphs-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-graphs-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-graphs-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-3-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion man/weekly_frequency_plot.Rd

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

0 comments on commit 81c7fb8

Please sign in to comment.