From 44dda87c17c95aafd56573626ee509839148ef47 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:18:54 +0200 Subject: [PATCH 1/7] require R4.1 and drop backports dependency --- DESCRIPTION | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ff01c38..4a060d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: nflplotR Title: NFL Logo Plots in 'ggplot2' and 'gt' -Version: 1.4.0.9002 +Version: 1.4.0.9003 Authors@R: person("Sebastian", "Carl", , "mrcaseb@gmail.com", role = c("aut", "cre")) Description: A set of functions to visualize National Football League @@ -9,9 +9,8 @@ License: MIT + file LICENSE URL: https://nflplotr.nflverse.com, https://github.com/nflverse/nflplotR BugReports: https://github.com/nflverse/nflplotR/issues Depends: - R (>= 3.5.0) + R (>= 4.1.0) Imports: - backports (>= 1.1.6), cachem (>= 1.0.0), cli (>= 3.0.0), data.table (>= 1.14.0), From 30c42f1cc20aa1986b4471cd162470f9d1647e86 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:19:23 +0200 Subject: [PATCH 2/7] switch to base pipe --- R/gt_nfl.R | 18 +++++++++--------- man/gt_nfl_cols_label.Rd | 6 +++--- man/gt_nfl_headshots.Rd | 2 +- man/gt_nfl_logos.Rd | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/R/gt_nfl.R b/R/gt_nfl.R index d010e87..fa03258 100644 --- a/R/gt_nfl.R +++ b/R/gt_nfl.R @@ -38,9 +38,9 @@ #' wordmark_b = tail(teams, 16) #' ) #' # create gt table and translate team names to logo/wordmark images -#' table <- df %>% -#' gt() %>% -#' gt_nfl_logos(columns = gt::starts_with("logo")) %>% +#' table <- df |> +#' gt() |> +#' gt_nfl_logos(columns = gt::starts_with("logo")) |> #' gt_nfl_wordmarks(columns = gt::starts_with("wordmark")) #' } gt_nfl_logos <- function(gt_object, @@ -104,12 +104,12 @@ gt_nfl_wordmarks <- function(gt_object, #' #' # create gt table and translate player IDs and team abbreviations #' # into headshots, logos, and wordmarks -#' table <- gt::gt(label_df) %>% +#' table <- gt::gt(label_df) |> #' nflplotR::gt_nfl_cols_label( #' columns = gt::starts_with("00"), #' type = "headshot" -#' ) %>% -#' nflplotR::gt_nfl_cols_label("LAC", type = "wordmark") %>% +#' ) |> +#' nflplotR::gt_nfl_cols_label("LAC", type = "wordmark") |> #' nflplotR::gt_nfl_cols_label("KC", type = "logo") #' } gt_nfl_cols_label <- function(gt_object, @@ -269,7 +269,7 @@ get_image_uri <- function(team_abbr, type = c("logo", "wordmark")) { #' ) #' #' # Replace player IDs with headshot images -#' table <- gt(df) %>% +#' table <- gt(df) |> #' gt_nfl_headshots("player_gsis") #' #' # Restore old options @@ -341,8 +341,8 @@ gt_render_image <- function(gt_tbl, ...){ temp_file <- tempfile(fileext = ".png") # webshot2 sends a message that can't be suppressed with suppressMessages() # so we capture the output and return it invisibly - output <- gt::gtsave(gt_tbl, temp_file, ...) %>% - utils::capture.output(type = "message") %>% + output <- gt::gtsave(gt_tbl, temp_file, ...) |> + utils::capture.output(type = "message") |> invisible() # if the output is something other than the annoying webshot message, print it if(!grepl("screenshot completed", output)) print(output) diff --git a/man/gt_nfl_cols_label.Rd b/man/gt_nfl_cols_label.Rd index 9012ca6..bc0cab1 100644 --- a/man/gt_nfl_cols_label.Rd +++ b/man/gt_nfl_cols_label.Rd @@ -51,12 +51,12 @@ label_df <- data.frame( # create gt table and translate player IDs and team abbreviations # into headshots, logos, and wordmarks -table <- gt::gt(label_df) \%>\% +table <- gt::gt(label_df) |> nflplotR::gt_nfl_cols_label( columns = gt::starts_with("00"), type = "headshot" - ) \%>\% - nflplotR::gt_nfl_cols_label("LAC", type = "wordmark") \%>\% + ) |> + nflplotR::gt_nfl_cols_label("LAC", type = "wordmark") |> nflplotR::gt_nfl_cols_label("KC", type = "logo") } } diff --git a/man/gt_nfl_headshots.Rd b/man/gt_nfl_headshots.Rd index 0141577..2350b87 100644 --- a/man/gt_nfl_headshots.Rd +++ b/man/gt_nfl_headshots.Rd @@ -62,7 +62,7 @@ df <- data.frame( ) # Replace player IDs with headshot images -table <- gt(df) \%>\% +table <- gt(df) |> gt_nfl_headshots("player_gsis") # Restore old options diff --git a/man/gt_nfl_logos.Rd b/man/gt_nfl_logos.Rd index 40e3d93..be03438 100644 --- a/man/gt_nfl_logos.Rd +++ b/man/gt_nfl_logos.Rd @@ -54,9 +54,9 @@ df <- data.frame( wordmark_b = tail(teams, 16) ) # create gt table and translate team names to logo/wordmark images -table <- df \%>\% - gt() \%>\% - gt_nfl_logos(columns = gt::starts_with("logo")) \%>\% +table <- df |> + gt() |> + gt_nfl_logos(columns = gt::starts_with("logo")) |> gt_nfl_wordmarks(columns = gt::starts_with("wordmark")) } } From cc0ff5d326619f68e43b3d5616e4939c597c3fd3 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:19:48 +0200 Subject: [PATCH 3/7] no more backports --- NAMESPACE | 7 +------ R/nflplotR-package.R | 7 +------ R/zzz.R | 1 - 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 065f343..8890c5c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,18 +32,13 @@ export(scale_color_nfl) export(scale_colour_nfl) export(scale_fill_nfl) export(valid_team_names) -if (getRversion() >= "4.0.0") { - importFrom(tools, R_user_dir) -} else { - importFrom(backports, R_user_dir) -} import(data.table) import(grid) importFrom(ggplot2,element_grob) importFrom(graphics,par) -importFrom(gt,"%>%") importFrom(lifecycle,deprecated) importFrom(nflreadr,nflverse_sitrep) importFrom(rlang,"%||%") importFrom(rlang,.data) +importFrom(tools,R_user_dir) importFrom(utils,capture.output) diff --git a/R/nflplotR-package.R b/R/nflplotR-package.R index 81d80a8..e98b46c 100644 --- a/R/nflplotR-package.R +++ b/R/nflplotR-package.R @@ -9,13 +9,8 @@ #' @importFrom ggplot2 element_grob #' @importFrom graphics par #' @importFrom lifecycle deprecated -#' @importFrom gt %>% #' @importFrom rlang .data %||% +#' @importFrom tools R_user_dir #' @importFrom utils capture.output -#' @rawNamespace if (getRversion() >= "4.0.0") { -#' importFrom(tools, R_user_dir) -#' } else { -#' importFrom(backports, R_user_dir) -#' } ## usethis namespace: end NULL diff --git a/R/zzz.R b/R/zzz.R index 6679702..472237d 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,7 +6,6 @@ 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") if (!dir.exists(cache_dir)) dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE) cache <- cachem::cache_disk(dir = cache_dir) From 108df23b210202e7e2efe610a2117c62bdfa8e39 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:19:58 +0200 Subject: [PATCH 4/7] no more magrittr pipe --- tests/testthat/test-nfl_team_factors.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-nfl_team_factors.R b/tests/testthat/test-nfl_team_factors.R index 2f49850..dbc506f 100644 --- a/tests/testthat/test-nfl_team_factors.R +++ b/tests/testthat/test-nfl_team_factors.R @@ -13,7 +13,7 @@ test_that("nfl team factors work", { plot_data <- mpg # add a new column by randomly sampling the above defined teams vector - plot_data$team <- sample(teams, nrow(mpg), replace = TRUE) %>% + plot_data$team <- sample(teams, nrow(mpg), replace = TRUE) |> nfl_team_factor(rev(team_abbr)) # Now we plot the data and facet by team abbreviation. ggplot automatically @@ -26,7 +26,7 @@ test_that("nfl team factors work", { # We'll change the order of facets by making another team name column and # converting it to an ordered factor. Again, this defaults to sort by division # and nick name in ascending order. - plot_data$ordered_team <- sample(teams, nrow(mpg), replace = TRUE) %>% + plot_data$ordered_team <- sample(teams, nrow(mpg), replace = TRUE) |> nfl_team_factor() # Let's check how the facets are ordered now. From d0fb18e724bbe7fabafb1cdee6f94891e04029ce Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:30:46 +0200 Subject: [PATCH 5/7] webshot 0.1.1 introduced a quiet arg it is 1.5 years old so it should be ok to require it --- DESCRIPTION | 2 +- R/gt_nfl.R | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4a060d5..8c1714a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,7 +33,7 @@ Suggests: rsvg (>= 2.0), testthat (>= 3.0.0), vdiffr (>= 1.0.2), - webshot2 (>= 0.1.0) + webshot2 (>= 0.1.1) Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/R/gt_nfl.R b/R/gt_nfl.R index fa03258..7713ab4 100644 --- a/R/gt_nfl.R +++ b/R/gt_nfl.R @@ -341,11 +341,7 @@ gt_render_image <- function(gt_tbl, ...){ temp_file <- tempfile(fileext = ".png") # webshot2 sends a message that can't be suppressed with suppressMessages() # so we capture the output and return it invisibly - output <- gt::gtsave(gt_tbl, temp_file, ...) |> - utils::capture.output(type = "message") |> - invisible() - # if the output is something other than the annoying webshot message, print it - if(!grepl("screenshot completed", output)) print(output) + output <- gt::gtsave(gt_tbl, temp_file, quiet = TRUE, ...) # get rid of the file when function exits on.exit(unlink(temp_file)) # remove margin from plots so we render the table only From 8a777c7259af3229713e0679056928c4495d5706 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:31:33 +0200 Subject: [PATCH 6/7] more namespace cleaning --- NAMESPACE | 1 - R/nflplotR-package.R | 1 - 2 files changed, 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 8890c5c..dbf9275 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,4 +41,3 @@ importFrom(nflreadr,nflverse_sitrep) importFrom(rlang,"%||%") importFrom(rlang,.data) importFrom(tools,R_user_dir) -importFrom(utils,capture.output) diff --git a/R/nflplotR-package.R b/R/nflplotR-package.R index e98b46c..df7d0a7 100644 --- a/R/nflplotR-package.R +++ b/R/nflplotR-package.R @@ -11,6 +11,5 @@ #' @importFrom lifecycle deprecated #' @importFrom rlang .data %||% #' @importFrom tools R_user_dir -#' @importFrom utils capture.output ## usethis namespace: end NULL From 341782f95fdcb62c2a9d1798f2142d19438f3e4d Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 31 Mar 2025 15:48:28 +0200 Subject: [PATCH 7/7] news bullet --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 70d6e18..bf868aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * The theme elements `element_nfl_logo()` and `element_nfl_wordmark()` now clean team abbreviations by calling `nflreadr::clean_team_abbrs()` and insert empty grobs for mismatches. * All geoms and theme elements will print more informative warnings about team abbreviation, or player ID mismatches. * The gt logo rendering functions now add alt text for accessibility and to silence an annoying pkgdown warning. (#69) +* nflplotR now requires R 4.1 because magick needs this R version. This also follows the [Tidyverse R version support rules](https://www.tidyverse.org/blog/2019/04/r-version-support/). (#71) # nflplotR 1.4.0