From bb65250fc7aa2d753dcac0c34bb20d3cadae6414 Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:48:18 +0200 Subject: [PATCH 01/10] get workflows up to date --- .github/workflows/R-CMD-check.yaml | 7 ++++-- .github/workflows/pkgdown.yaml | 6 +++-- .github/workflows/test-coverage.yaml | 37 +++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 74c377f..7e813f5 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -7,7 +7,9 @@ on: branches: [main, master] workflow_dispatch: -name: R-CMD-check +name: R-CMD-check.yaml + +permissions: read-all jobs: R-CMD-check: @@ -20,7 +22,7 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} @@ -51,3 +53,4 @@ jobs: - uses: r-lib/actions/check-r-package@v2 with: upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 16499f1..cd0a292 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -9,7 +9,9 @@ on: types: [published] workflow_dispatch: -name: pkgdown +name: pkgdown.yaml + +permissions: read-all jobs: pkgdown: @@ -44,7 +46,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: clean: false branch: gh-pages diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 11faedd..9882260 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -6,12 +6,13 @@ on: pull_request: branches: [main, master] -name: test-coverage +name: test-coverage.yaml + +permissions: read-all jobs: test-coverage: runs-on: ubuntu-latest - timeout-minutes: 20 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -24,9 +25,37 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::covr + extra-packages: any::covr, any::xml2 needs: coverage - name: Test coverage - run: covr::codecov() + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package From d0292b566dfd064264162389c9d94b16cf2e0a02 Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:48:31 +0200 Subject: [PATCH 02/10] add revdepcheck workflow --- .github/workflows/revdepcheck.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/revdepcheck.yaml diff --git a/.github/workflows/revdepcheck.yaml b/.github/workflows/revdepcheck.yaml new file mode 100644 index 0000000..b8919d4 --- /dev/null +++ b/.github/workflows/revdepcheck.yaml @@ -0,0 +1,19 @@ +# Workflow derived from https://github.com/r-devel/recheck?tab=readme-ov-file#how-to-use-with-github-actions +on: + workflow_dispatch: + inputs: + which: + type: choice + description: Which dependents to check + options: + - strong + - most + +name: Reverse dependency check + +jobs: + revdep_check: + name: Reverse check ${{ inputs.which }} dependents + uses: r-devel/recheck/.github/workflows/recheck.yml@v1 + with: + which: ${{ inputs.which }} From 8877ad9400b4e5362b7b2c4e72003b61d823fb88 Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:48:55 +0200 Subject: [PATCH 03/10] drop rappdirs and use backports instead --- DESCRIPTION | 4 ++-- R/zzz.R | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c267b34..95ae5ae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: nflplotR Title: NFL Logo Plots in 'ggplot2' and 'gt' -Version: 1.3.1.9000 +Version: 1.3.1.9001 Authors@R: person("Sebastian", "Carl", , "mrcaseb@gmail.com", role = c("aut", "cre")) Description: A set of functions to visualize National Football League @@ -11,6 +11,7 @@ BugReports: https://github.com/nflverse/nflplotR/issues Depends: R (>= 3.5.0) Imports: + backports (>= 1.1.6), cachem (>= 1.0.0), cli (>= 3.0.0), data.table (>= 1.14.0), @@ -22,7 +23,6 @@ Imports: magick (>= 2.7.3), memoise (>= 2.0.0), nflreadr (>= 1.3.2), - rappdirs (>= 0.3.0), rlang (>= 0.4.11), scales (>= 1.1.0) Suggests: diff --git a/R/zzz.R b/R/zzz.R index 873efb0..6679702 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,8 +6,9 @@ if(!memoise_option %in% c("memory", "filesystem", "off")) memoise_option <- "memory" if(memoise_option == "filesystem"){ - cache_dir <- rappdirs::user_cache_dir(appname = "nflplotR") - dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE) + backports::import(pkgname, "R_user_dir") + cache_dir <- R_user_dir("nflplotR", "cache") + if (!dir.exists(cache_dir)) dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE) cache <- cachem::cache_disk(dir = cache_dir) } From 7e1f3b731be6c76c021f116572ff9ead0dc152fc Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:49:08 +0200 Subject: [PATCH 04/10] update badges --- README.Rmd | 4 ++-- README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.Rmd b/README.Rmd index 733965c..848ab94 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,12 +17,12 @@ knitr::opts_chunk$set( [![CRAN status](https://img.shields.io/cran/v/nflplotR?style=flat-square&logo=R&label=CRAN)](https://CRAN.R-project.org/package=nflplotR) -[![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/nflplotR)](https://CRAN.R-project.org/package=nflplotR) +[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/nflplotR)](https://CRAN.R-project.org/package=nflplotR) [![Dev status](https://img.shields.io/github/r-package/v/nflverse/nflplotR/main?label=dev%20version&style=flat-square&logo=github)](https://nflplotr.nflverse.com) [![R build status](https://img.shields.io/github/actions/workflow/status/nflverse/nflplotR/R-CMD-check.yaml?label=R%20check&style=flat-square&logo=github)](https://github.com/nflverse/nflplotR/actions) -[![Codecov test coverage](https://codecov.io/gh/nflverse/nflplotR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nflverse/nflplotR?branch=main) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg?style=flat-square)](https://lifecycle.r-lib.org/articles/stages.html) [![nflverse support](https://img.shields.io/discord/789805604076126219?color=7289da&label=nflverse%20support&logo=discord&logoColor=fff&style=flat-square)](https://discord.com/invite/5Er2FBnnQa) +[![Codecov test coverage](https://codecov.io/gh/nflverse/nflplotR/graph/badge.svg)](https://app.codecov.io/gh/nflverse/nflplotR) The goal of nflplotR is to provide functions and geoms that help visualization of NFL related analysis. It provides a ggplot2 geom that does the heavy lifting of plotting NFL logos in high quality, with correct aspect ratio and possible transparency. diff --git a/README.md b/README.md index e68fafa..4ac179a 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,17 @@ [![CRAN status](https://img.shields.io/cran/v/nflplotR?style=flat-square&logo=R&label=CRAN)](https://CRAN.R-project.org/package=nflplotR) [![CRAN -downloads](http://cranlogs.r-pkg.org/badges/grand-total/nflplotR)](https://CRAN.R-project.org/package=nflplotR) +downloads](https://cranlogs.r-pkg.org/badges/grand-total/nflplotR)](https://CRAN.R-project.org/package=nflplotR) [![Dev status](https://img.shields.io/github/r-package/v/nflverse/nflplotR/main?label=dev%20version&style=flat-square&logo=github)](https://nflplotr.nflverse.com) [![R build status](https://img.shields.io/github/actions/workflow/status/nflverse/nflplotR/R-CMD-check.yaml?label=R%20check&style=flat-square&logo=github)](https://github.com/nflverse/nflplotR/actions) -[![Codecov test -coverage](https://codecov.io/gh/nflverse/nflplotR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nflverse/nflplotR?branch=main) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg?style=flat-square)](https://lifecycle.r-lib.org/articles/stages.html) [![nflverse support](https://img.shields.io/discord/789805604076126219?color=7289da&label=nflverse%20support&logo=discord&logoColor=fff&style=flat-square)](https://discord.com/invite/5Er2FBnnQa) +[![Codecov test +coverage](https://codecov.io/gh/nflverse/nflplotR/graph/badge.svg)](https://app.codecov.io/gh/nflverse/nflplotR) The goal of nflplotR is to provide functions and geoms that help From 0dbe7c6841d21d3c6de3bbd075391640c375628a Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:52:39 +0200 Subject: [PATCH 05/10] path is done in ggpath --- R/build_grobs.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/build_grobs.R b/R/build_grobs.R index c164ce9..8042627 100644 --- a/R/build_grobs.R +++ b/R/build_grobs.R @@ -1,6 +1,6 @@ # INTERNAL HELPER THAT BUILDS THE GROBS FOR # GEOM LOGOS, WORDMARKS AND HEADSHOTS -build_grobs <- function(i, alpha, colour, data, type = c("teams", "headshots", "wordmarks", "path")) { +build_grobs <- function(i, alpha, colour, data, type = c("teams", "headshots", "wordmarks")) { make_null <- FALSE type <- rlang::arg_match(type) if(type == "teams") { @@ -11,8 +11,6 @@ build_grobs <- function(i, alpha, colour, data, type = c("teams", "headshots", " team_abbr <- data$team_abbr[i] image_to_read <- wordmark_list[[team_abbr]] if (is.na(team_abbr) | is.null(image_to_read)) make_null <- TRUE - } else if (type == "path"){ - image_to_read <- data$path[i] } else { gsis <- data$player_gsis[i] if (is.na(gsis)) make_null <- TRUE From 5f9dc58ad57944bd42050c7f1ea84d5e3b86a7ae Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:56:29 +0200 Subject: [PATCH 06/10] remove deprecated axis scales and themes --- NAMESPACE | 6 -- R/scale_nfl.R | 216 ------------------------------------------ R/theme_nfl.R | 80 ---------------- man/scale_axes_nfl.Rd | 209 ---------------------------------------- man/theme_nfl.Rd | 57 ----------- 5 files changed, 568 deletions(-) delete mode 100644 R/theme_nfl.R delete mode 100644 man/scale_axes_nfl.Rd delete mode 100644 man/theme_nfl.Rd diff --git a/NAMESPACE b/NAMESPACE index 51916a6..918b22f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,12 +31,6 @@ export(nflverse_sitrep) export(scale_color_nfl) export(scale_colour_nfl) export(scale_fill_nfl) -export(scale_x_nfl) -export(scale_x_nfl_headshots) -export(scale_y_nfl) -export(scale_y_nfl_headshots) -export(theme_x_nfl) -export(theme_y_nfl) export(valid_team_names) import(data.table) import(grid) diff --git a/R/scale_nfl.R b/R/scale_nfl.R index c7d4b74..4c1bb06 100644 --- a/R/scale_nfl.R +++ b/R/scale_nfl.R @@ -109,219 +109,3 @@ scale_fill_nfl <- function(type = c("primary", "secondary"), guide = guide ) } - - -# Axis Scales ------------------------------------------------------------- - -#' Axis Scales for NFL Team Logos -#' -#' @description `r lifecycle::badge("deprecated")` -#' -#' These functions map NFL team names to their team logos and make them -#' available as axis labels -#' @details The scale translates the NFL team abbreviations into raw image -#' html and places the html as axis labels. Because of the way ggplots are -#' constructed, it is necessary to adjust the [`ggplot2::theme`] after calling this -#' scale. This can be done by calling [`theme_x_nfl()`] or [`theme_y_nfl()`] -#' or alternatively by manually changing the relevant `axis.text` to -#' [`ggtext::element_markdown()`]. However, this will only work if an underlying -#' dependency, "gridtext", is installed with a newer version than 0.1.4 -#' @inheritParams ggplot2::scale_x_discrete -#' @param size The logo size in pixels. It is applied as height for an x-scale -#' and as width for an y-scale. -#' @name scale_axes_nfl -#' @keywords internal -#' @return A discrete ggplot2 scale created with [`ggplot2::scale_x_discrete`] or -#' [`ggplot2::scale_y_discrete`]. -#' @aliases NULL -#' @seealso [`theme_x_nfl()`], [`theme_y_nfl()`] -#' @examples -#' \donttest{ -#' library(nflplotR) -#' library(ggplot2) -#' -#' team_abbr <- valid_team_names() -#' # remove conference logos from this example -#' team_abbr <- team_abbr[!team_abbr %in% c("AFC", "NFC")] -#' -#' df <- data.frame( -#' random_value = runif(length(team_abbr), 0, 1), -#' teams = team_abbr -#' ) -#' -#' if (utils::packageVersion("gridtext") > "0.1.4" && FALSE){ -#' # use logos for x-axis -#' ggplot(df, aes(x = teams, y = random_value)) + -#' geom_col(aes(color = teams, fill = teams), width = 0.5) + -#' scale_color_nfl(type = "secondary") + -#' scale_fill_nfl(alpha = 0.4) + -#' scale_x_nfl() + -#' theme_minimal() + -#' # theme_*_nfl requires gridtext version > 0.1.4 -#' theme_x_nfl() -#' -#' # use logos for y-axis -#' ggplot(df, aes(y = teams, x = random_value)) + -#' geom_col(aes(color = teams, fill = teams), width = 0.5) + -#' scale_color_nfl(type = "secondary") + -#' scale_fill_nfl(alpha = 0.4) + -#' scale_y_nfl() + -#' theme_minimal() + -#' # theme_*_nfl requires gridtext version > 0.1.4 -#' theme_y_nfl() -#'} -#' ############################################################################# -#' # Headshot Examples -#' ############################################################################# -#' library(nflplotR) -#' library(ggplot2) -#' -#' # Silence an nflreadr message that is irrelevant here -#' old <- options(nflreadr.cache_warning = FALSE) -#' -#' dfh <- data.frame( -#' random_value = runif(9, 0, 1), -#' player_gsis = c("00-0033873", -#' "00-0026498", -#' "00-0035228", -#' "00-0031237", -#' "00-0036355", -#' "00-0019596", -#' "00-0033077", -#' "00-0012345", -#' "00-0031280") -#' ) -#' -#' if (utils::packageVersion("gridtext") > "0.1.4" && FALSE){ -#' # use headshots for x-axis -#' ggplot(dfh, aes(x = player_gsis, y = random_value)) + -#' geom_col(width = 0.5) + -#' scale_x_nfl_headshots() + -#' theme_minimal() + -#' # theme_*_nfl requires gridtext version > 0.1.4 -#' theme_x_nfl() -#' -#' # use headshots for y-axis -#' ggplot(dfh, aes(y = player_gsis, x = random_value)) + -#' geom_col(width = 0.5) + -#' scale_y_nfl_headshots() + -#' theme_minimal() + -#' # theme_*_nfl requires gridtext version > 0.1.4 -#' theme_y_nfl() -#'} -#' # Restore old options -#' options(old) -#' } -NULL - -#' @rdname scale_axes_nfl -#' @export -scale_x_nfl <- function(..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "bottom", - size = 12) { - - lifecycle::deprecate_warn( - "1.3.0", - "scale_x_nfl()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - - position <- rlang::arg_match0(position, c("top", "bottom")) - - ggplot2::scale_x_discrete( - ..., - labels = function(x) { - logo_html(x, type = "height", size = size) - }, - expand = expand, - guide = guide, - position = position - ) -} - -#' @rdname scale_axes_nfl -#' @export -scale_y_nfl <- function(..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "left", - size = 12) { - - lifecycle::deprecate_warn( - "1.3.0", - "scale_y_nfl()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - - position <- rlang::arg_match0(position, c("left", "right")) - - ggplot2::scale_y_discrete( - ..., - labels = function(x) { - logo_html(x, type = "width", size = size) - }, - expand = expand, - guide = guide, - position = position - ) -} - -#' @rdname scale_axes_nfl -#' @export -scale_x_nfl_headshots <- function(..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "bottom", - size = 20) { - - lifecycle::deprecate_warn( - "1.3.0", - "scale_x_nfl_headshots()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - - position <- rlang::arg_match0(position, c("top", "bottom")) - - ggplot2::scale_x_discrete( - ..., - labels = function(x) { - headshot_html(x, type = "height", size = size) - }, - expand = expand, - guide = guide, - position = position - ) -} - -#' @rdname scale_axes_nfl -#' @export -scale_y_nfl_headshots <- function(..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "left", - size = 30) { - - lifecycle::deprecate_warn( - "1.3.0", - "scale_y_nfl_headshots()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - - position <- rlang::arg_match0(position, c("left", "right")) - - ggplot2::scale_y_discrete( - ..., - labels = function(x) { - headshot_html(x, type = "width", size = size) - }, - expand = expand, - guide = guide, - position = position - ) -} diff --git a/R/theme_nfl.R b/R/theme_nfl.R deleted file mode 100644 index e58e02b..0000000 --- a/R/theme_nfl.R +++ /dev/null @@ -1,80 +0,0 @@ -#' Theme for NFL Team Logos -#' -#' @description `r lifecycle::badge("deprecated")` -#' -#' These functions are convenience wrappers around a theme call -#' that activates markdown in x-axis and y-axis labels -#' using [`ggtext::element_markdown()`]. -#' @details These functions are a wrapper around the function calls -#' `ggplot2::theme(axis.text.x = ggtext::element_markdown())` as well as -#' `ggplot2::theme(axis.text.y = ggtext::element_markdown())`. -#' They are made to be used in conjunction with [`scale_x_nfl()`] and -#' [`scale_y_nfl()`] respectively. -#' @name theme_nfl -#' @aliases NULL -#' @keywords internal -#' @return A ggplot2 theme created with [`ggplot2::theme`]. -#' @seealso [`theme_x_nfl()`], [`theme_y_nfl()`] -#' @examples -#' \donttest{ -#' library(nflplotR) -#' library(ggplot2) -#' -#' team_abbr <- valid_team_names() -#' # remove conference logos from this example -#' team_abbr <- team_abbr[!team_abbr %in% c("AFC", "NFC", "NFL")] -#' -#' df <- data.frame( -#' random_value = runif(length(team_abbr), 0, 1), -#' teams = team_abbr -#' ) -#' if (utils::packageVersion("gridtext") > "0.1.4"){ -#' ggplot(df, aes(x = teams, y = random_value)) + -#' geom_col(aes(color = teams, fill = teams), width = 0.5) + -#' scale_color_nfl(type = "secondary") + -#' scale_fill_nfl(alpha = 0.4) + -#' scale_x_nfl() + -#' theme_minimal() + -#' # theme_*_nfl requires gridtext version > 0.1.4 -#' theme_x_nfl() -#' } -#' } -NULL - -#' @rdname theme_nfl -#' @export -theme_x_nfl <- function(){ - lifecycle::deprecate_warn( - "1.3.0", - "theme_x_nfl()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - if (!is_installed("ggtext")) { - cli::cli_abort(c( - "Package {.val ggtext} required to create this scale.", - 'Please install it with {.var install.packages("ggtext")}' - )) - } - loadNamespace("gridtext", versionCheck = list(op = ">", version = "0.1.4")) - ggplot2::theme(axis.text.x = ggtext::element_markdown()) -} - -#' @rdname theme_nfl -#' @export -theme_y_nfl <- function(){ - lifecycle::deprecate_warn( - "1.3.0", - "theme_y_nfl()", - details = "This function is slow and inferior to theme elements; - use `element_*()` functions instead." - ) - if (!is_installed("ggtext")) { - cli::cli_abort(c( - "Package {.val ggtext} required to create this scale.", - 'Please install it with {.var install.packages("ggtext")}' - )) - } - loadNamespace("gridtext", versionCheck = list(op = ">", version = "0.1.4")) - ggplot2::theme(axis.text.y = ggtext::element_markdown()) -} diff --git a/man/scale_axes_nfl.Rd b/man/scale_axes_nfl.Rd deleted file mode 100644 index e996876..0000000 --- a/man/scale_axes_nfl.Rd +++ /dev/null @@ -1,209 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale_nfl.R -\name{scale_axes_nfl} -\alias{scale_x_nfl} -\alias{scale_y_nfl} -\alias{scale_x_nfl_headshots} -\alias{scale_y_nfl_headshots} -\title{Axis Scales for NFL Team Logos} -\usage{ -scale_x_nfl( - ..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "bottom", - size = 12 -) - -scale_y_nfl( - ..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "left", - size = 12 -) - -scale_x_nfl_headshots( - ..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "bottom", - size = 20 -) - -scale_y_nfl_headshots( - ..., - expand = ggplot2::waiver(), - guide = ggplot2::waiver(), - position = "left", - size = 30 -) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} - \describe{ - \item{\code{palette}}{A palette function that when called with a single integer -argument (the number of levels in the scale) returns the values that -they should take (e.g., \code{\link[scales:pal_hue]{scales::pal_hue()}}).} - \item{\code{breaks}}{One of: -\itemize{ -\item \code{NULL} for no breaks -\item \code{waiver()} for the default breaks (the scale limits) -\item A character vector of breaks -\item A function that takes the limits as input and returns breaks -as output. Also accepts rlang \link[rlang:as_function]{lambda} function -notation. -}} - \item{\code{limits}}{One of: -\itemize{ -\item \code{NULL} to use the default scale values -\item A character vector that defines possible values of the scale and their -order -\item A function that accepts the existing (automatic) values and returns -new ones. Also accepts rlang \link[rlang:as_function]{lambda} function -notation. -}} - \item{\code{drop}}{Should unused factor levels be omitted from the scale? -The default, \code{TRUE}, uses the levels that appear in the data; -\code{FALSE} includes the levels in the factor. Please note that to display -every level in a legend, the layer should use \code{show.legend = TRUE}.} - \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show -missing values, and do so by default. If you want to remove missing values -from a discrete scale, specify \code{na.translate = FALSE}.} - \item{\code{na.value}}{If \code{na.translate = TRUE}, what aesthetic value should the -missing values be displayed as? Does not apply to position scales -where \code{NA} is always placed at the far right.} - \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} - \item{\code{labels}}{One of: -\itemize{ -\item \code{NULL} for no labels -\item \code{waiver()} for the default labels computed by the -transformation object -\item A character vector giving labels (must be same length as \code{breaks}) -\item An expression vector (must be the same length as breaks). See ?plotmath for details. -\item A function that takes the breaks as input and returns labels -as output. Also accepts rlang \link[rlang:as_function]{lambda} function -notation. -}} - \item{\code{call}}{The \code{call} used to construct the scale for reporting messages.} - \item{\code{super}}{The super class to use for the constructed scale} - }} - -\item{expand}{For position scales, a vector of range expansion constants used to add some -padding around the data to ensure that they are placed some distance -away from the axes. Use the convenience function \code{\link[ggplot2:expansion]{expansion()}} -to generate the values for the \code{expand} argument. The defaults are to -expand the scale by 5\% on each side for continuous variables, and by -0.6 units on each side for discrete variables.} - -\item{guide}{A function used to create a guide or its name. See -\code{\link[ggplot2:guides]{guides()}} for more information.} - -\item{position}{For position scales, The position of the axis. -\code{left} or \code{right} for y axes, \code{top} or \code{bottom} for x axes.} - -\item{size}{The logo size in pixels. It is applied as height for an x-scale -and as width for an y-scale.} -} -\value{ -A discrete ggplot2 scale created with \code{\link[ggplot2:scale_discrete]{ggplot2::scale_x_discrete}} or -\code{\link[ggplot2:scale_discrete]{ggplot2::scale_y_discrete}}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -These functions map NFL team names to their team logos and make them -available as axis labels -} -\details{ -The scale translates the NFL team abbreviations into raw image -html and places the html as axis labels. Because of the way ggplots are -constructed, it is necessary to adjust the \code{\link[ggplot2:theme]{ggplot2::theme}} after calling this -scale. This can be done by calling \code{\link[=theme_x_nfl]{theme_x_nfl()}} or \code{\link[=theme_y_nfl]{theme_y_nfl()}} -or alternatively by manually changing the relevant \code{axis.text} to -\code{\link[ggtext:element_markdown]{ggtext::element_markdown()}}. However, this will only work if an underlying -dependency, "gridtext", is installed with a newer version than 0.1.4 -} -\examples{ -\donttest{ -library(nflplotR) -library(ggplot2) - -team_abbr <- valid_team_names() -# remove conference logos from this example -team_abbr <- team_abbr[!team_abbr \%in\% c("AFC", "NFC")] - -df <- data.frame( - random_value = runif(length(team_abbr), 0, 1), - teams = team_abbr -) - -if (utils::packageVersion("gridtext") > "0.1.4" && FALSE){ - # use logos for x-axis - ggplot(df, aes(x = teams, y = random_value)) + - geom_col(aes(color = teams, fill = teams), width = 0.5) + - scale_color_nfl(type = "secondary") + - scale_fill_nfl(alpha = 0.4) + - scale_x_nfl() + - theme_minimal() + - # theme_*_nfl requires gridtext version > 0.1.4 - theme_x_nfl() - - # use logos for y-axis - ggplot(df, aes(y = teams, x = random_value)) + - geom_col(aes(color = teams, fill = teams), width = 0.5) + - scale_color_nfl(type = "secondary") + - scale_fill_nfl(alpha = 0.4) + - scale_y_nfl() + - theme_minimal() + - # theme_*_nfl requires gridtext version > 0.1.4 - theme_y_nfl() -} -############################################################################# -# Headshot Examples -############################################################################# -library(nflplotR) -library(ggplot2) - -# Silence an nflreadr message that is irrelevant here -old <- options(nflreadr.cache_warning = FALSE) - -dfh <- data.frame( - random_value = runif(9, 0, 1), - player_gsis = c("00-0033873", - "00-0026498", - "00-0035228", - "00-0031237", - "00-0036355", - "00-0019596", - "00-0033077", - "00-0012345", - "00-0031280") -) - -if (utils::packageVersion("gridtext") > "0.1.4" && FALSE){ - # use headshots for x-axis - ggplot(dfh, aes(x = player_gsis, y = random_value)) + - geom_col(width = 0.5) + - scale_x_nfl_headshots() + - theme_minimal() + - # theme_*_nfl requires gridtext version > 0.1.4 - theme_x_nfl() - - # use headshots for y-axis - ggplot(dfh, aes(y = player_gsis, x = random_value)) + - geom_col(width = 0.5) + - scale_y_nfl_headshots() + - theme_minimal() + - # theme_*_nfl requires gridtext version > 0.1.4 - theme_y_nfl() -} -# Restore old options -options(old) -} -} -\seealso{ -\code{\link[=theme_x_nfl]{theme_x_nfl()}}, \code{\link[=theme_y_nfl]{theme_y_nfl()}} -} -\keyword{internal} diff --git a/man/theme_nfl.Rd b/man/theme_nfl.Rd deleted file mode 100644 index 5206db6..0000000 --- a/man/theme_nfl.Rd +++ /dev/null @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_nfl.R -\name{theme_nfl} -\alias{theme_x_nfl} -\alias{theme_y_nfl} -\title{Theme for NFL Team Logos} -\usage{ -theme_x_nfl() - -theme_y_nfl() -} -\value{ -A ggplot2 theme created with \code{\link[ggplot2:theme]{ggplot2::theme}}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -These functions are convenience wrappers around a theme call -that activates markdown in x-axis and y-axis labels -using \code{\link[ggtext:element_markdown]{ggtext::element_markdown()}}. -} -\details{ -These functions are a wrapper around the function calls -\code{ggplot2::theme(axis.text.x = ggtext::element_markdown())} as well as -\code{ggplot2::theme(axis.text.y = ggtext::element_markdown())}. -They are made to be used in conjunction with \code{\link[=scale_x_nfl]{scale_x_nfl()}} and -\code{\link[=scale_y_nfl]{scale_y_nfl()}} respectively. -} -\examples{ -\donttest{ -library(nflplotR) -library(ggplot2) - -team_abbr <- valid_team_names() -# remove conference logos from this example -team_abbr <- team_abbr[!team_abbr \%in\% c("AFC", "NFC", "NFL")] - -df <- data.frame( - random_value = runif(length(team_abbr), 0, 1), - teams = team_abbr -) -if (utils::packageVersion("gridtext") > "0.1.4"){ - ggplot(df, aes(x = teams, y = random_value)) + - geom_col(aes(color = teams, fill = teams), width = 0.5) + - scale_color_nfl(type = "secondary") + - scale_fill_nfl(alpha = 0.4) + - scale_x_nfl() + - theme_minimal() + - # theme_*_nfl requires gridtext version > 0.1.4 - theme_x_nfl() -} -} -} -\seealso{ -\code{\link[=theme_x_nfl]{theme_x_nfl()}}, \code{\link[=theme_y_nfl]{theme_y_nfl()}} -} -\keyword{internal} From ae0fe52a722ef3712089607912b29e5f546d3350 Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 15:57:38 +0200 Subject: [PATCH 07/10] finally get rid of thos deps --- DESCRIPTION | 2 -- 1 file changed, 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 95ae5ae..73afe1c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,8 +28,6 @@ Imports: Suggests: base64enc (>= 0.1-3), covr, - ggtext (>= 0.1.1), - gridtext (>= 0.1.4), knitr, rmarkdown, rstudioapi (>= 0.13), From 55785556d3f303f32b7e284cfb4a5c2a18654c7a Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 16:00:36 +0200 Subject: [PATCH 08/10] News bullet --- NEWS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 9274e38..2a23b36 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # nflplotR (development version) -* Updated the New York Jets logo to their new design introduced in the 2024 offseason. (#62) +* Updated the New York Jets logo to their new design introduced in the 2024 off-season. (#62) +* Drop dependency to package rappdirs and create an optional user cache with base R's implementation. To support older R versions, nflplotR now imports the backports package. (#63) +* nflplotR v1.3.0 deprecated the functions `scale_x_nfl`, `scale_y_nfl`, `scale_x_nfl_headshots`, `scale_y_nfl_headshots`, `theme_x_nfl`, `theme_y_nfl`. They are completely removed from the source now. (#63) # nflplotR 1.3.1 From 1a6d3e0d893b77a31c76bced5c8f480c77459138 Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 16:14:49 +0200 Subject: [PATCH 09/10] support rhub v2 --- .github/workflows/rhub.yaml | 95 +++++++++++++++++++++++++++++++++++++ R/utils.R | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/rhub.yaml diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..95b0ded --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/R/utils.R b/R/utils.R index 862b188..b48c92d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -85,7 +85,7 @@ NULL release_bullets <- function() { c( '`devtools::check_mac_release()`', - '`rhub::check_for_cran(email = "mrcaseb@gmail.com", show_status = FALSE)`', + '`rhub::rhub_check()`', '`pkgdown::check_pkgdown()`', '`usethis::use_tidy_thanks()`', NULL From dc1db07b7a946260d776c5304a44ac05f9a8dd8c Mon Sep 17 00:00:00 2001 From: Sebastian Carl Date: Thu, 15 Aug 2024 16:27:16 +0200 Subject: [PATCH 10/10] gotta force import here as it's in tools --- R/zzz.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index 6679702..7ad20ed 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,8 +6,8 @@ if(!memoise_option %in% c("memory", "filesystem", "off")) memoise_option <- "memory" if(memoise_option == "filesystem"){ - backports::import(pkgname, "R_user_dir") - cache_dir <- R_user_dir("nflplotR", "cache") + backports::import(pkgname, "R_user_dir", force = TRUE) + cache_dir <- backports::R_user_dir("nflplotR", "cache") if (!dir.exists(cache_dir)) dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE) cache <- cachem::cache_disk(dir = cache_dir) }