diff --git a/.github/workflows/pkgdown-gh-pages-clean.yaml b/.github/workflows/pkgdown-gh-pages-clean.yaml deleted file mode 100644 index 7862ddc2..00000000 --- a/.github/workflows/pkgdown-gh-pages-clean.yaml +++ /dev/null @@ -1,35 +0,0 @@ -on: - workflow_dispatch: - -name: Clean pkgdown manually - -jobs: - pkgdown-gh-pages-manual: - runs-on: windows-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - install-r: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: | - local::. - any::pkgdown - any::reactable - ropenspain/rostemplate - needs: website - - - name: Deploy package - run: | - git config --local user.name "github-actions[bot]" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, clean = TRUE)' - diff --git a/.github/workflows/rostemplate-gh-pages.yaml b/.github/workflows/rostemplate-gh-pages.yaml index 827092f5..518c87da 100644 --- a/.github/workflows/rostemplate-gh-pages.yaml +++ b/.github/workflows/rostemplate-gh-pages.yaml @@ -38,5 +38,5 @@ jobs: run: | git config --local user.name "github-actions[bot]" git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, clean = FALSE)' + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, clean = TRUE)' diff --git a/.github/workflows/wipe-cache.yaml b/.github/workflows/wipe-cache.yaml index cde45a16..5b828742 100644 --- a/.github/workflows/wipe-cache.yaml +++ b/.github/workflows/wipe-cache.yaml @@ -1,7 +1,8 @@ name: Clear GHA caches manually on: workflow_dispatch: - + schedule: + - cron: '0 22 2 * *' jobs: cache-clear: runs-on: ubuntu-latest diff --git a/CITATION.cff b/CITATION.cff index 8845c5b7..f63382fc 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -8,7 +8,7 @@ message: 'To cite package "tidyBdE" in publications use:' type: software license: GPL-3.0-or-later title: 'tidyBdE: Download Data from Bank of Spain' -version: 0.3.4.9000 +version: 0.3.5 doi: 10.5281/zenodo.4673496 abstract: Tools to download data series from 'Banco de España' ('BdE') on 'tibble' format. 'Banco de España' is the national central bank and, within the framework @@ -32,7 +32,7 @@ preferred-citation: affiliation: rOpenSpain doi: 10.5281/zenodo.4673496 year: '2024' - version: 0.3.4.9000 + version: 0.3.5 url: https://ropenspain.github.io/tidyBdE/ abstract: Tools to download data series from Banco de España (BdE) on tibble format. Banco de España is the national central bank and, within the framework of the diff --git a/DESCRIPTION b/DESCRIPTION index 0bc0d3b9..c8d08c85 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tidyBdE Title: Download Data from Bank of Spain -Version: 0.3.4.9000 +Version: 0.3.5 Authors@R: person("Diego", "H. Herrero", , "dev.dieghernan@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-8457-4658", affiliation = "rOpenSpain")) @@ -32,7 +32,8 @@ Suggests: VignetteBuilder: knitr Config/Needs/coverage: covr -Config/Needs/website: reactable, styler, tidyverse, ropenspain/rostemplate +Config/Needs/website: reactable, styler, tidyverse, + ropenspain/rostemplate, devtools Config/testthat/edition: 3 Config/testthat/parallel: true Copyright: See file inst/COPYRIGHTS diff --git a/NAMESPACE b/NAMESPACE index fa074fb8..87bdeafe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,11 +14,11 @@ export(bde_ind_ibex_daily) export(bde_ind_ibex_monthly) export(bde_ind_population) export(bde_ind_unemployment_rate) -export(bde_palettes) export(bde_parse_dates) export(bde_rose_pal) export(bde_series_full_load) export(bde_series_load) +export(bde_tidy_palettes) export(bde_vivid_pal) export(scale_color_bde_c) export(scale_color_bde_d) diff --git a/NEWS.md b/NEWS.md index 9a965420..40d677a2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,12 +1,13 @@ -# tidyBdE (development version) +# tidyBdE 0.3.5 Mostly changes on the color functions: - `bde_vivid_pal()` and `bde_rose_pal()` have been superseded. Use the new - function `bde_palettes()` instead. -- `scale_color_bde_d()` and friends leverage now on `bde_palettes()`, and + function `bde_tidy_palettes()` instead. +- `scale_color_bde_d()` and friends leverage now on `bde_tidy_palettes()`, and these functions gain two new arguments: `alpha` y `rev`. - Update and review documentation. +- New palette named `bde_qual_pal`. # tidyBdE 0.3.4 diff --git a/R/bde_palettes.R b/R/bde_tidy_palettes.R similarity index 66% rename from R/bde_palettes.R rename to R/bde_tidy_palettes.R index caf79a88..103ee672 100644 --- a/R/bde_palettes.R +++ b/R/bde_tidy_palettes.R @@ -20,12 +20,21 @@ #' @examples #' #' # BdE vivid pal -#' scales::show_col(bde_palettes(palette = "bde_vivid_pal"), labels = FALSE) +#' scales::show_col(bde_tidy_palettes(palette = "bde_vivid_pal"), +#' labels = FALSE +#' ) #' #' # BdE rose pal -#' scales::show_col(bde_palettes(palette = "bde_rose_pal"), labels = FALSE) -bde_palettes <- function(n = 6, palette = c("bde_vivid_pal", "bde_rose_pal"), - alpha = NULL, rev = FALSE) { +#' scales::show_col(bde_tidy_palettes(palette = "bde_rose_pal"), labels = FALSE) +#' +#' # BdE qual pal +#' scales::show_col(bde_tidy_palettes(palette = "bde_qual_pal"), labels = FALSE) +bde_tidy_palettes <- function(n = 6, + palette = c( + "bde_vivid_pal", "bde_rose_pal", + "bde_qual_pal" + ), + alpha = NULL, rev = FALSE) { palette <- match.arg(palette) cols <- switch(palette, @@ -36,6 +45,10 @@ bde_palettes <- function(n = 6, palette = c("bde_vivid_pal", "bde_rose_pal"), "bde_rose_pal" = c( "#b7365c", "#cb6e8a", "#db9aad", "#0a50a1", "#5385bd", "#89AEDA" + ), + "bde_qual_pal" = c( + "#b55b4a", "#2e76bc", "#fece64", + "#68be57", "#858788", "#f9b4af" ) ) diff --git a/R/scales.R b/R/scales.R index f515a7ff..857f7166 100644 --- a/R/scales.R +++ b/R/scales.R @@ -17,10 +17,10 @@ #' #' @name scales_bde #' -#' @param palette Name of the BdE palette to apply. One of `"bde_vivid_pal"`, -#' `"bde_rose_pal"`. See [bde_palettes()] for details. +#' @param palette Name of the BdE palette to apply. See [bde_tidy_palettes()] +#' for details. #' -#' @inheritParams bde_palettes +#' @inheritParams bde_tidy_palettes #' #' @param ... Further arguments of [ggplot2::discrete_scale()] or #' [ggplot2::continuous_scale()]. @@ -45,14 +45,15 @@ #' #' ggplot(txsamp, aes(x = sales, y = median)) + #' geom_point(aes(colour = city)) + -#' scale_color_bde_d("bde_rose_pal") + +#' scale_color_bde_d("bde_qual_pal") + #' theme_minimal() #' -scale_color_bde_d <- function(palette = c("bde_vivid_pal", "bde_rose_pal"), - alpha = NULL, rev = FALSE, ...) { +scale_color_bde_d <- function( + palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, + rev = FALSE, ...) { palette <- match.arg(palette) - cols_v <- bde_palettes(palette = palette, alpha = alpha, rev = rev) + cols_v <- bde_tidy_palettes(palette = palette, alpha = alpha, rev = rev) pal <- scales::manual_pal(cols_v) ggplot2::discrete_scale( @@ -72,11 +73,12 @@ scale_colour_bde_d <- scale_color_bde_d #' @rdname scales_bde #' @name scales_bde #' @export -scale_fill_bde_d <- function(palette = c("bde_vivid_pal", "bde_rose_pal"), - alpha = NULL, rev = FALSE, ...) { +scale_fill_bde_d <- function( + palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, + rev = FALSE, ...) { palette <- match.arg(palette) - cols_v <- bde_palettes(palette = palette, alpha = alpha, rev = rev) + cols_v <- bde_tidy_palettes(palette = palette, alpha = alpha, rev = rev) pal <- scales::manual_pal(cols_v) ggplot2::discrete_scale( @@ -91,17 +93,22 @@ scale_fill_bde_d <- function(palette = c("bde_vivid_pal", "bde_rose_pal"), #' @rdname scales_bde #' @name scales_bde #' @export -scale_color_bde_c <- function(palette = c("bde_rose_pal", "bde_vivid_pal"), - alpha = NULL, rev = FALSE, ...) { +scale_color_bde_c <- function( + palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, + rev = FALSE, ...) { palette <- match.arg(palette) cols <- switch(palette, - "bde_vivid_pal" = bde_palettes(6, "bde_vivid_pal", + "bde_vivid_pal" = bde_tidy_palettes(6, "bde_vivid_pal", alpha = alpha, rev = rev ), - "bde_rose_pal" = bde_palettes(6, "bde_rose_pal", + "bde_qual_pal" = bde_tidy_palettes(6, "bde_qual_pal", + alpha = alpha, + rev = rev + ), + "bde_rose_pal" = bde_tidy_palettes(6, "bde_rose_pal", alpha = alpha, rev = rev )[c(1, 2, 3, 6, 5, 4)] @@ -124,17 +131,22 @@ scale_colour_bde_c <- scale_color_bde_c #' @rdname scales_bde #' @name scales_bde #' @export -scale_fill_bde_c <- function(palette = c("bde_rose_pal", "bde_vivid_pal"), - alpha = NULL, rev = FALSE, ...) { +scale_fill_bde_c <- function( + palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, + rev = FALSE, ...) { palette <- match.arg(palette) cols <- switch(palette, - "bde_vivid_pal" = bde_palettes(6, "bde_vivid_pal", + "bde_vivid_pal" = bde_tidy_palettes(6, "bde_vivid_pal", + alpha = alpha, + rev = rev + ), + "bde_qual_pal" = bde_tidy_palettes(6, "bde_qual_pal", alpha = alpha, rev = rev ), - "bde_rose_pal" = bde_palettes(6, "bde_rose_pal", + "bde_rose_pal" = bde_tidy_palettes(6, "bde_rose_pal", alpha = alpha, rev = rev )[c(1, 2, 3, 6, 5, 4)] diff --git a/R/series.R b/R/series.R index e45a27b5..f12aa626 100644 --- a/R/series.R +++ b/R/series.R @@ -24,7 +24,7 @@ #' #' #' @return -#' A [tibble][tibble::tibble] with a field "Date" and : +#' A [tibble][tibble::tibble] with a field `Date` and : #' - With `out_format = "wide"` each series is presented in a separate #' column with the name defined by `series_label`. #' - With `out_format = "long"` the tibble would have two more columns, @@ -291,7 +291,7 @@ bde_series_load <- function(series_code, series_label = NULL, #' @param extract_metadata Logical `TRUE/FALSE`. On `TRUE` the output is the #' metadata of the requested series. #' -#' @return A [tibble][tibble::tibble] with a field "Date" and the alias of the +#' @return A [tibble][tibble::tibble] with a field `Date` and the alias of the #' fields series as described on the catalogs. See [bde_catalog_load()]. #' #' @note diff --git a/R/superseded.R b/R/superseded.R index 59dfe1e2..7f02ebce 100644 --- a/R/superseded.R +++ b/R/superseded.R @@ -3,7 +3,8 @@ #' @description #' `r lifecycle::badge('superseded')` #' -#' These functions have been superseded, see [bde_palettes()] as a replacement. +#' These functions have been superseded, see [bde_tidy_palettes()] as a +#' replacement. #' #' Custom palettes based on the publications of BdE. #' @@ -29,7 +30,7 @@ bde_vivid_pal <- function(...) { if (requireNamespace("lifecycle", quietly = TRUE)) { lifecycle::deprecate_soft( "0.3.5", "bde_vivid_pal()", - "bde_palettes()" + "bde_tidy_palettes()" ) } @@ -44,7 +45,7 @@ bde_rose_pal <- function(...) { if (requireNamespace("lifecycle", quietly = TRUE)) { lifecycle::deprecate_soft( "0.3.5", "bde_rose_pal()", - "bde_palettes()" + "bde_tidy_palettes()" ) } pal <- c("#b7365c", "#cb6e8a", "#db9aad", "#0a50a1", "#5385bd", "#89AEDA") diff --git a/R/theme_tidybde.R b/R/theme_tidybde.R index 69516e88..b5826380 100644 --- a/R/theme_tidybde.R +++ b/R/theme_tidybde.R @@ -38,7 +38,7 @@ #' names(series_TC_pivot) <- c("x", "y") #' #' ggplot(series_TC_pivot, aes(x = x, y = y)) + -#' geom_line(linewidth = 0.8, color = bde_palettes(n = 1)) + +#' geom_line(linewidth = 0.8, color = bde_tidy_palettes(n = 1)) + #' labs( #' title = "Title", #' subtitle = "Some metric", diff --git a/README.Rmd b/README.Rmd index 52cea94d..6edb1d50 100644 --- a/README.Rmd +++ b/README.Rmd @@ -126,8 +126,8 @@ BdE: ```{r chart, fig.asp=0.7} ggplot(time_series, aes(x = Date, y = EUR_GBP_XR)) + - geom_line(colour = bde_palettes(n = 1)) + - geom_smooth(method = "gam", colour = bde_palettes(n = 2)[2]) + + geom_line(colour = bde_tidy_palettes(n = 1)) + + geom_smooth(method = "gam", colour = bde_tidy_palettes(n = 2)[2]) + labs( title = "EUR/GBP Exchange Rate (2010-2020)", subtitle = "%", diff --git a/README.md b/README.md index e58b0b65..940fb571 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,8 @@ publications of BdE: ``` r ggplot(time_series, aes(x = Date, y = EUR_GBP_XR)) + - geom_line(colour = bde_palettes(n = 1)) + - geom_smooth(method = "gam", colour = bde_palettes(n = 2)[2]) + + geom_line(colour = bde_tidy_palettes(n = 1)) + + geom_smooth(method = "gam", colour = bde_tidy_palettes(n = 2)[2]) + labs( title = "EUR/GBP Exchange Rate (2010-2020)", subtitle = "%", @@ -231,7 +231,7 @@ A BibTeX entry for LaTeX users is doi = {10.5281/zenodo.4673496}, author = {Diego {H. Herrero}}, year = {2024}, - version = {0.3.4.9000}, + version = {0.3.5}, url = {https://ropenspain.github.io/tidyBdE/}, abstract = {Tools to download data series from Banco de España (BdE) on tibble format. Banco de España is the national central bank and, within the framework of the Single Supervisory Mechanism (SSM), the supervisor of the Spanish banking system along with the European Central Bank. This package is in no way sponsored endorsed or administered by Banco de España.}, } diff --git a/codemeta.json b/codemeta.json index 7d04b533..73fc2cfe 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,13 @@ "codeRepository": "https://github.com/rOpenSpain/tidyBdE", "issueTracker": "https://github.com/rOpenSpain/tidyBdE/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.3.4.9000", + "version": "0.3.5", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", + "runtimePlatform": "R version 4.3.2 (2023-10-31)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -192,7 +192,7 @@ }, "applicationCategory": "Macroeconomics", "isPartOf": "https://ropenspain.es/", - "fileSize": "273.717KB", + "fileSize": "273.083KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/inst/schemaorg.json b/inst/schemaorg.json index f8803807..bbdbcd07 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -28,8 +28,8 @@ "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", - "version": "0.3.4.9000" + "runtimePlatform": "R version 4.3.2 (2023-10-31)", + "version": "0.3.5" }, { "id": "https://doi.org/10.5281/zenodo.4673496", diff --git a/man/bde_pals.Rd b/man/bde_pals.Rd index 73ef9b43..5cc7b254 100644 --- a/man/bde_pals.Rd +++ b/man/bde_pals.Rd @@ -18,7 +18,8 @@ A palette of colors. \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} -These functions have been superseded, see \code{\link[=bde_palettes]{bde_palettes()}} as a replacement. +These functions have been superseded, see \code{\link[=bde_tidy_palettes]{bde_tidy_palettes()}} as a +replacement. Custom palettes based on the publications of BdE. } diff --git a/man/bde_series_full_load.Rd b/man/bde_series_full_load.Rd index 4c310c64..560f4297 100644 --- a/man/bde_series_full_load.Rd +++ b/man/bde_series_full_load.Rd @@ -39,7 +39,7 @@ debugging.} metadata of the requested series.} } \value{ -A \link[tibble:tibble]{tibble} with a field "Date" and the alias of the +A \link[tibble:tibble]{tibble} with a field \code{Date} and the alias of the fields series as described on the catalogs. See \code{\link[=bde_catalog_load]{bde_catalog_load()}}. } \description{ diff --git a/man/bde_series_load.Rd b/man/bde_series_load.Rd index 08009573..36552c87 100644 --- a/man/bde_series_load.Rd +++ b/man/bde_series_load.Rd @@ -49,7 +49,7 @@ debugging.} metadata of the requested series.} } \value{ -A \link[tibble:tibble]{tibble} with a field "Date" and : +A \link[tibble:tibble]{tibble} with a field \code{Date} and : \itemize{ \item With \code{out_format = "wide"} each series is presented in a separate column with the name defined by \code{series_label}. diff --git a/man/bde_palettes.Rd b/man/bde_tidy_palettes.Rd similarity index 67% rename from man/bde_palettes.Rd rename to man/bde_tidy_palettes.Rd index a1486296..7b2f1296 100644 --- a/man/bde_palettes.Rd +++ b/man/bde_tidy_palettes.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bde_palettes.R -\name{bde_palettes} -\alias{bde_palettes} +% Please edit documentation in R/bde_tidy_palettes.R +\name{bde_tidy_palettes} +\alias{bde_tidy_palettes} \title{BdE color palettes} \usage{ -bde_palettes( +bde_tidy_palettes( n = 6, - palette = c("bde_vivid_pal", "bde_rose_pal"), + palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE ) @@ -34,10 +34,15 @@ with a maximum of 6 colors. \examples{ # BdE vivid pal -scales::show_col(bde_palettes(palette = "bde_vivid_pal"), labels = FALSE) +scales::show_col(bde_tidy_palettes(palette = "bde_vivid_pal"), + labels = FALSE +) # BdE rose pal -scales::show_col(bde_palettes(palette = "bde_rose_pal"), labels = FALSE) +scales::show_col(bde_tidy_palettes(palette = "bde_rose_pal"), labels = FALSE) + +# BdE qual pal +scales::show_col(bde_tidy_palettes(palette = "bde_qual_pal"), labels = FALSE) } \seealso{ Other bde_plot: diff --git a/man/figures/README-chart-1.png b/man/figures/README-chart-1.png index 5521feca..c885261e 100644 Binary files a/man/figures/README-chart-1.png and b/man/figures/README-chart-1.png differ diff --git a/man/figures/README-macroseries-1.png b/man/figures/README-macroseries-1.png index c12227f1..b70215ac 100644 Binary files a/man/figures/README-macroseries-1.png and b/man/figures/README-macroseries-1.png differ diff --git a/man/scales_bde.Rd b/man/scales_bde.Rd index 8d086fd9..9a0a4b76 100644 --- a/man/scales_bde.Rd +++ b/man/scales_bde.Rd @@ -11,36 +11,36 @@ \title{BdE scales for \CRANpkg{ggplot2}.} \usage{ scale_color_bde_d( - palette = c("bde_vivid_pal", "bde_rose_pal"), + palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_fill_bde_d( - palette = c("bde_vivid_pal", "bde_rose_pal"), + palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_color_bde_c( - palette = c("bde_rose_pal", "bde_vivid_pal"), + palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_fill_bde_c( - palette = c("bde_rose_pal", "bde_vivid_pal"), + palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) } \arguments{ -\item{palette}{Name of the BdE palette to apply. One of \code{"bde_vivid_pal"}, -\code{"bde_rose_pal"}. See \code{\link[=bde_palettes]{bde_palettes()}} for details.} +\item{palette}{Name of the BdE palette to apply. See \code{\link[=bde_tidy_palettes]{bde_tidy_palettes()}} +for details.} \item{alpha}{An alpha-transparency level in the range \verb{[0,1]} (\code{0} means transparent and \code{1} means opaque). A missing, i.e., \code{alpha = NULL}, does @@ -80,7 +80,7 @@ ggplot(txsamp, aes(x = sales, y = median)) + ggplot(txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city)) + - scale_color_bde_d("bde_rose_pal") + + scale_color_bde_d("bde_qual_pal") + theme_minimal() } @@ -88,7 +88,7 @@ ggplot(txsamp, aes(x = sales, y = median)) + \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}, \code{\link[ggplot2:continuous_scale]{ggplot2::continuous_scale()}} Other bde_plot: -\code{\link{bde_palettes}()}, +\code{\link{bde_tidy_palettes}()}, \code{\link{theme_tidybde}()} } \concept{bde_plot} diff --git a/man/theme_tidybde.Rd b/man/theme_tidybde.Rd index 127ccb43..fb800f21 100644 --- a/man/theme_tidybde.Rd +++ b/man/theme_tidybde.Rd @@ -47,7 +47,7 @@ if (nrow(series_TC) > 0) { names(series_TC_pivot) <- c("x", "y") ggplot(series_TC_pivot, aes(x = x, y = y)) + - geom_line(linewidth = 0.8, color = bde_palettes(n = 1)) + + geom_line(linewidth = 0.8, color = bde_tidy_palettes(n = 1)) + labs( title = "Title", subtitle = "Some metric", @@ -62,7 +62,7 @@ if (nrow(series_TC) > 0) { \code{\link[ggplot2:ggtheme]{ggplot2::theme_classic()}} Other bde_plot: -\code{\link{bde_palettes}()}, +\code{\link{bde_tidy_palettes}()}, \code{\link{scales_bde}} } \concept{bde_plot} diff --git a/tests/testthat/_snaps/bde_palettes.md b/tests/testthat/_snaps/bde_tidy_palettes.md similarity index 51% rename from tests/testthat/_snaps/bde_palettes.md rename to tests/testthat/_snaps/bde_tidy_palettes.md index 5bafde06..ed0145db 100644 --- a/tests/testthat/_snaps/bde_palettes.md +++ b/tests/testthat/_snaps/bde_tidy_palettes.md @@ -1,15 +1,15 @@ # Test error Code - bde_palettes(palette = "none") + bde_tidy_palettes(palette = "none") Condition Error in `match.arg()`: - ! 'arg' should be one of "bde_vivid_pal", "bde_rose_pal" + ! 'arg' should be one of "bde_vivid_pal", "bde_rose_pal", "bde_qual_pal" # Max value Code - nmore <- bde_palettes(n = 23) + nmore <- bde_tidy_palettes(n = 23) Message tidyBdE> bde_vivid_pal has 6, requested 23. Returning 6 colors. diff --git a/tests/testthat/_snaps/superseded.md b/tests/testthat/_snaps/superseded.md index bb51dba8..5c4924b1 100644 --- a/tests/testthat/_snaps/superseded.md +++ b/tests/testthat/_snaps/superseded.md @@ -5,7 +5,7 @@ Condition Warning: `bde_vivid_pal()` was deprecated in tidyBdE 0.3.5. - i Please use `bde_palettes()` instead. + i Please use `bde_tidy_palettes()` instead. # bde_rose_pal @@ -14,5 +14,5 @@ Condition Warning: `bde_rose_pal()` was deprecated in tidyBdE 0.3.5. - i Please use `bde_palettes()` instead. + i Please use `bde_tidy_palettes()` instead. diff --git a/tests/testthat/test-bde_palettes.R b/tests/testthat/test-bde_palettes.R deleted file mode 100644 index 1b39c7a8..00000000 --- a/tests/testthat/test-bde_palettes.R +++ /dev/null @@ -1,46 +0,0 @@ -test_that("Test error", { - expect_snapshot(bde_palettes(palette = "none"), - error = TRUE - ) -}) - - -test_that("Max value", { - ok <- bde_palettes(n = 6) - - expect_snapshot(nmore <- bde_palettes(n = 23)) - - expect_identical(ok, nmore) -}) - - -test_that("Switch pal", { - ok <- bde_palettes(n = 6) - other <- bde_palettes(n = 6, palette = "bde_rose_pal") - - expect_false(any(ok == other)) -}) - - - -test_that("test n", { - ok <- bde_palettes(n = 6) - ok3 <- bde_palettes(n = 3) - - expect_identical(ok[seq_len(3)], ok3) -}) - - -test_that("test rev", { - ok <- bde_palettes(n = 6) - ok3 <- bde_palettes(n = 3, rev = TRUE) - - expect_identical(ok[rev(seq_len(3))], ok3) -}) - -test_that("test alpha", { - ok <- bde_palettes(n = 6) - ok3 <- bde_palettes(n = 6, alpha = 0.2) - - expect_identical(ggplot2::alpha(ok, 0.2), ok3) -}) diff --git a/tests/testthat/test-bde_tidy_palettes.R b/tests/testthat/test-bde_tidy_palettes.R new file mode 100644 index 00000000..393d90ae --- /dev/null +++ b/tests/testthat/test-bde_tidy_palettes.R @@ -0,0 +1,49 @@ +test_that("Test error", { + expect_snapshot(bde_tidy_palettes(palette = "none"), + error = TRUE + ) +}) + + +test_that("Max value", { + ok <- bde_tidy_palettes(n = 6) + + expect_snapshot(nmore <- bde_tidy_palettes(n = 23)) + + expect_identical(ok, nmore) +}) + + +test_that("Switch pal", { + ok <- bde_tidy_palettes(n = 6) + other <- bde_tidy_palettes(n = 6, palette = "bde_rose_pal") + expect_false(any(ok == other)) + + other2 <- bde_tidy_palettes(n = 6, palette = "bde_qual_pal") + expect_false(any(ok == other2)) + expect_false(any(other == other2)) +}) + + + +test_that("test n", { + ok <- bde_tidy_palettes(n = 6) + ok3 <- bde_tidy_palettes(n = 3) + + expect_identical(ok[seq_len(3)], ok3) +}) + + +test_that("test rev", { + ok <- bde_tidy_palettes(n = 6) + ok3 <- bde_tidy_palettes(n = 3, rev = TRUE) + + expect_identical(ok[rev(seq_len(3))], ok3) +}) + +test_that("test alpha", { + ok <- bde_tidy_palettes(n = 6) + ok3 <- bde_tidy_palettes(n = 6, alpha = 0.2) + + expect_identical(ggplot2::alpha(ok, 0.2), ok3) +}) diff --git a/tests/testthat/test-scales.R b/tests/testthat/test-scales.R index dcd8d449..e62b5e8b 100644 --- a/tests/testthat/test-scales.R +++ b/tests/testthat/test-scales.R @@ -30,6 +30,13 @@ test_that("Discrete scale", { expect_false(any(mod == mod4)) + # Another pal + p5 <- p + scale_color_bde_d(palette = "bde_qual_pal") + mod5 <- ggplot2::layer_data(p5)$colour + + expect_false(any(mod == mod5)) + + # Another aes pf <- ggplot2::ggplot(d) + ggplot2::geom_point(ggplot2::aes(x, y, fill = l), shape = 21) diff --git a/tests/testthat/test-superseded.R b/tests/testthat/test-superseded.R index 0c3d936d..47e20432 100644 --- a/tests/testthat/test-superseded.R +++ b/tests/testthat/test-superseded.R @@ -3,7 +3,7 @@ test_that("bde_vivid_pal", { expect_snapshot(vpal <- bde_vivid_pal()(3)) expect_identical( - bde_palettes(n = 3, "bde_vivid_pal"), + bde_tidy_palettes(n = 3, "bde_vivid_pal"), vpal ) }) @@ -13,7 +13,7 @@ test_that("bde_rose_pal", { expect_snapshot(vpal <- bde_rose_pal()(4)) expect_identical( - bde_palettes(n = 4, "bde_rose_pal"), + bde_tidy_palettes(n = 4, "bde_rose_pal"), vpal ) }) diff --git a/vignettes/articles/Main_Macroeconomic_Series.Rmd b/vignettes/articles/Main_Macroeconomic_Series.Rmd index c64ea9a9..cfe6933b 100644 --- a/vignettes/articles/Main_Macroeconomic_Series.Rmd +++ b/vignettes/articles/Main_Macroeconomic_Series.Rmd @@ -30,9 +30,9 @@ library(dplyr) library(tidyr) -col <- bde_palettes(1, "bde_rose_pal") +col <- bde_tidy_palettes(1, "bde_rose_pal") date <- Sys.Date() -ny <- as.numeric(format(date, format = "%Y")) - 4 +ny <- as.numeric(format(date, format = "%Y")) - 6 nd <- as.Date(paste0(ny, "-12-31")) br <- seq(nd, Sys.Date(), "6 months") diff --git a/vignettes/chart-1.png b/vignettes/chart-1.png index 2da3f832..9427c637 100644 Binary files a/vignettes/chart-1.png and b/vignettes/chart-1.png differ diff --git a/vignettes/tidyBdE.Rmd b/vignettes/tidyBdE.Rmd index 03e6672e..59a705ef 100644 --- a/vignettes/tidyBdE.Rmd +++ b/vignettes/tidyBdE.Rmd @@ -86,8 +86,8 @@ BdE: ```r ggplot(time_series, aes(x = Date, y = EUR_GBP_XR)) + - geom_line(colour = bde_palettes(n = 1)) + - geom_smooth(method = "gam", colour = bde_palettes(n = 2)[2]) + + geom_line(colour = bde_tidy_palettes(n = 1)) + + geom_smooth(method = "gam", colour = bde_tidy_palettes(n = 2)[2]) + labs( title = "EUR/GBP Exchange Rate (2010-2020)", subtitle = "%", diff --git a/vignettes/tidyBdE.Rmd.orig b/vignettes/tidyBdE.Rmd.orig index 1a998be9..c3fdd5d1 100644 --- a/vignettes/tidyBdE.Rmd.orig +++ b/vignettes/tidyBdE.Rmd.orig @@ -96,8 +96,8 @@ BdE: ```{r chart, eval=TRUE, fig.cap='EUR/GBP Exchange Rate (2010-2020)', fig.asp=0.7} ggplot(time_series, aes(x = Date, y = EUR_GBP_XR)) + - geom_line(colour = bde_palettes(n=1)) + - geom_smooth(method = "gam", colour = bde_palettes(n=2)[2]) + + geom_line(colour = bde_tidy_palettes(n=1)) + + geom_smooth(method = "gam", colour = bde_tidy_palettes(n=2)[2]) + labs(title = "EUR/GBP Exchange Rate (2010-2020)", subtitle = "%", caption = "Source: BdE") +