From 6c1c0b95ce42c1934f8224d11e093d32039397c0 Mon Sep 17 00:00:00 2001 From: Jack Davison Date: Tue, 28 May 2024 09:30:06 +0100 Subject: [PATCH] feat: add `progress` arg to `polarMap()` etc. --- NEWS.md | 2 ++ R/polar_annulusMap.R | 6 ++++-- R/polar_diffMap.R | 9 ++++++--- R/polar_freqMap.R | 4 +++- R/polar_percentileMap.R | 4 +++- R/polar_polarMap.R | 12 +++++++++++- R/polar_pollroseMap.R | 4 +++- R/polar_windroseMap.R | 4 +++- R/utils-map.R | 5 +++-- man/annulusMap.Rd | 9 +++++++++ man/diffMap.Rd | 9 +++++++++ man/freqMap.Rd | 9 +++++++++ man/percentileMap.Rd | 9 +++++++++ man/polarMap.Rd | 9 +++++++++ man/pollroseMap.Rd | 9 +++++++++ man/windroseMap.Rd | 9 +++++++++ 16 files changed, 101 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index b78dbea..f8c85f1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Pairwise statistics (e.g., `"robust_slope"`) are now supported by `polarMap()`. (#72) +* The `polarMap()` family has gained the `progress` argument, allowing users to switch the progress bar on and off. + ## Bug fixes * Vectors greater than length 1 passed to `popup` in the `polarMap()` argument will no longer error when `type = NULL`. diff --git a/R/polar_annulusMap.R b/R/polar_annulusMap.R index 4ddb2bb..9248215 100644 --- a/R/polar_annulusMap.R +++ b/R/polar_annulusMap.R @@ -61,6 +61,7 @@ annulusMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -116,7 +117,7 @@ annulusMap <- function(data, } # cut data - data <- openair::cutData(x = data, type = type, ...) + data <- openair::cutData(x = data, type = type %||% "default", ...) # deal with popups if (length(popup) > 1) { @@ -195,7 +196,8 @@ annulusMap <- function(data, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { diff --git a/R/polar_diffMap.R b/R/polar_diffMap.R index bce3b19..646c0f2 100644 --- a/R/polar_diffMap.R +++ b/R/polar_diffMap.R @@ -80,6 +80,7 @@ diffMap <- function(before, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -220,7 +221,8 @@ diffMap <- function(before, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { @@ -323,7 +325,8 @@ create_polar_diffmarkers <- popup = NULL, label = NULL, d.fig, - dropcol = "conc") { + dropcol = "conc", + progress = TRUE) { # make temp directory dir <- tempdir() @@ -400,7 +403,7 @@ create_polar_diffmarkers <- by = c(latitude, longitude, split_col) ) %>% dplyr::mutate( - plot = purrr::map2(before, after, fun, .progress = "Creating Polar Markers"), + plot = purrr::map2(before, after, fun, .progress = ifelse(progress, "Creating Polar Markers", FALSE)), url = paste0(dir, "/", .data[[latitude]], "_", .data[[longitude]], "_", .data[[split_col]], "_", id, ".png") ) diff --git a/R/polar_freqMap.R b/R/polar_freqMap.R index 9fadb3f..217e84a 100644 --- a/R/polar_freqMap.R +++ b/R/polar_freqMap.R @@ -84,6 +84,7 @@ freqMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -214,7 +215,8 @@ freqMap <- function(data, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { diff --git a/R/polar_percentileMap.R b/R/polar_percentileMap.R index a05609c..2166388 100644 --- a/R/polar_percentileMap.R +++ b/R/polar_percentileMap.R @@ -70,6 +70,7 @@ percentileMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -187,7 +188,8 @@ percentileMap <- function(data, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { diff --git a/R/polar_polarMap.R b/R/polar_polarMap.R index f594ea9..22eba71 100644 --- a/R/polar_polarMap.R +++ b/R/polar_polarMap.R @@ -269,6 +269,14 @@ #' [ggplot2::facet_wrap()]. The default, `NULL`, results in a roughly square #' grid of panels. #' +#' @param progress *Show a progress bar?* +#' +#' *default:* `TRUE` | *scope:* dynamic & static +#' +#' By default, a progress bar is shown to visualise the function's progress +#' creating individual polar markers. This option allows this to be turned +#' off, if desired. +#' #' @param control **Deprecated.** Please use `type`. #' #' @inheritDotParams openair::polarPlot -mydata -pollutant -x -limits -type @@ -317,6 +325,7 @@ polarMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # list pairwise statistics @@ -473,7 +482,8 @@ polarMap <- function(data, d.fig = d.fig, popup = popup, label = label, - dropcol = funpoll + dropcol = funpoll, + progress = progress ) if (!static) { diff --git a/R/polar_pollroseMap.R b/R/polar_pollroseMap.R index f767339..f319177 100644 --- a/R/polar_pollroseMap.R +++ b/R/polar_pollroseMap.R @@ -73,6 +73,7 @@ pollroseMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -167,7 +168,8 @@ pollroseMap <- function(data, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { diff --git a/R/polar_windroseMap.R b/R/polar_windroseMap.R index cda3cb5..63fadea 100644 --- a/R/polar_windroseMap.R +++ b/R/polar_windroseMap.R @@ -77,6 +77,7 @@ windroseMap <- function(data, d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL) { # check basemap providers are valid @@ -173,7 +174,8 @@ windroseMap <- function(data, split_col = split_col, d.fig = d.fig, popup = popup, - label = label + label = label, + progress = progress ) if (static) { diff --git a/R/utils-map.R b/R/utils-map.R index 7f3500f..0b4d1b5 100644 --- a/R/utils-map.R +++ b/R/utils-map.R @@ -423,7 +423,8 @@ create_polar_markers <- popup = NULL, label = NULL, d.fig, - dropcol = "conc") { + dropcol = "conc", + progress = TRUE) { # make temp directory dir <- tempdir() @@ -468,7 +469,7 @@ create_polar_markers <- plots_df <- nested_df %>% dplyr::mutate( - plot = purrr::map(data, fun, .progress = "Creating Polar Markers"), + plot = purrr::map(data, fun, .progress = ifelse(progress, "Creating Polar Markers", FALSE)), url = paste0( dir, "/", diff --git a/man/annulusMap.Rd b/man/annulusMap.Rd index c968d74..a7f264e 100644 --- a/man/annulusMap.Rd +++ b/man/annulusMap.Rd @@ -30,6 +30,7 @@ annulusMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -265,6 +266,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:polarAnnulus]{openair::polarAnnulus}} \describe{ diff --git a/man/diffMap.Rd b/man/diffMap.Rd index 95acdc1..34b29cc 100644 --- a/man/diffMap.Rd +++ b/man/diffMap.Rd @@ -31,6 +31,7 @@ diffMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -255,6 +256,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:polarPlot]{openair::polarPlot}} \describe{ diff --git a/man/freqMap.Rd b/man/freqMap.Rd index f022372..5e29d63 100644 --- a/man/freqMap.Rd +++ b/man/freqMap.Rd @@ -30,6 +30,7 @@ freqMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -275,6 +276,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:polarFreq]{openair::polarFreq}} \describe{ diff --git a/man/percentileMap.Rd b/man/percentileMap.Rd index 8c586f0..0dbfd4d 100644 --- a/man/percentileMap.Rd +++ b/man/percentileMap.Rd @@ -30,6 +30,7 @@ percentileMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -262,6 +263,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:percentileRose]{openair::percentileRose}} \describe{ diff --git a/man/polarMap.Rd b/man/polarMap.Rd index fa92305..104d254 100644 --- a/man/polarMap.Rd +++ b/man/polarMap.Rd @@ -31,6 +31,7 @@ polarMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -278,6 +279,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:polarPlot]{openair::polarPlot}} \describe{ diff --git a/man/pollroseMap.Rd b/man/pollroseMap.Rd index 9cb2027..425151f 100644 --- a/man/pollroseMap.Rd +++ b/man/pollroseMap.Rd @@ -30,6 +30,7 @@ pollroseMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -264,6 +265,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:pollutionRose]{openair::pollutionRose}} \describe{ diff --git a/man/windroseMap.Rd b/man/windroseMap.Rd index 6a6c07b..a065c51 100644 --- a/man/windroseMap.Rd +++ b/man/windroseMap.Rd @@ -29,6 +29,7 @@ windroseMap( d.fig = 3.5, static = FALSE, static.nrow = NULL, + progress = TRUE, ..., control = NULL ) @@ -242,6 +243,14 @@ Controls the number of rows of panels on a static map when multiple \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. The default, \code{NULL}, results in a roughly square grid of panels.} +\item{progress}{\emph{Show a progress bar?} + +\emph{default:} \code{TRUE} | \emph{scope:} dynamic & static + +By default, a progress bar is shown to visualise the function's progress +creating individual polar markers. This option allows this to be turned +off, if desired.} + \item{...}{ Arguments passed on to \code{\link[openair:windRose]{openair::windRose}} \describe{