diff --git a/DESCRIPTION b/DESCRIPTION index 4f98268..825640b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,9 +16,11 @@ Imports: DBI, devtools, dplyr, + ffscrapr, gganimate, ggplot2, ggrepel, + gitcreds, glue, gsisdecoder, gt, @@ -32,6 +34,7 @@ Imports: purrr, rcmdcheck, remotes, + renv, rlang, rmarkdown, roxygen2, diff --git a/R/create_gt_ovr_fantasy_standings.R b/R/create_gt_ovr_fantasy_standings.R index 986119e..1d84425 100644 --- a/R/create_gt_ovr_fantasy_standings.R +++ b/R/create_gt_ovr_fantasy_standings.R @@ -226,7 +226,9 @@ table_ovr_rb_fantasy <- function(num_players = NULL, week_min = 1 ) %>% # Clean up player names in defined player column - nuclearff::replace_player_names(player_col = "player_display_name") + nuclearff::replace_player_names(player_col = "player_display_name") %>% + # Clean up team names e.g., LA to LAR + nuclearff::replace_team_names() # Pull WR roster information and player IDs rb_data <- nuclearff::get_player_data(seasons, @@ -240,7 +242,9 @@ table_ovr_rb_fantasy <- function(num_players = NULL, pfr_id ) %>% # Clean up player names in defined player column - nuclearff::replace_player_names(player_col = "player_display_name") + nuclearff::replace_player_names(player_col = "player_display_name") %>% + # Clean up team names e.g., LA to LAR + nuclearff::replace_team_names() # Combine PBP data with roster information and IDs rb_stats <- rb_pbp_stats %>% @@ -426,7 +430,9 @@ table_ovr_wr_fantasy <- function(num_players = NULL, week_min = 1 ) %>% # Clean up player names in defined player column - nuclearff::replace_player_names(player_col = "player_display_name") + nuclearff::replace_player_names(player_col = "player_display_name") %>% + # Clean up team names e.g., LA to LAR + nuclearff::replace_team_names() # Pull WR roster information and player IDs wr_data <- nuclearff::get_player_data(seasons, diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 5bf2a9c..3d689e7 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.1 pkgdown_sha: ~ articles: setup_pbp_db: setup_pbp_db.html -last_built: 2024-10-08T03:12Z +last_built: 2024-10-10T15:55Z urls: reference: https://github.com/NuclearAnalyticsLab/nuclearff/reference article: https://github.com/NuclearAnalyticsLab/nuclearff/articles diff --git a/inst/logos/png/logo-500x500.png b/inst/logos/png/logo-500x500.png new file mode 100644 index 0000000..582511f Binary files /dev/null and b/inst/logos/png/logo-500x500.png differ diff --git a/inst/logos/png/nuclearff-2color.png b/inst/logos/png/nuclearff-2color.png new file mode 100644 index 0000000..eba60eb Binary files /dev/null and b/inst/logos/png/nuclearff-2color.png differ diff --git a/inst/logos/png/nuclearff-blue-pink-stroke.png b/inst/logos/png/nuclearff-blue-pink-stroke.png new file mode 100644 index 0000000..233e335 Binary files /dev/null and b/inst/logos/png/nuclearff-blue-pink-stroke.png differ diff --git a/inst/logos/png/nuclearff-hori-blue-pink-stroke.png b/inst/logos/png/nuclearff-hori-blue-pink-stroke.png new file mode 100644 index 0000000..b15fdae Binary files /dev/null and b/inst/logos/png/nuclearff-hori-blue-pink-stroke.png differ diff --git a/inst/logos/svg/atom/nuclearff-2-color-transparent.svg b/inst/logos/svg/atom/nuclearff-2-color-transparent.svg new file mode 100644 index 0000000..0274ad1 --- /dev/null +++ b/inst/logos/svg/atom/nuclearff-2-color-transparent.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inst/logos/svg/atom/nuclearff-bw-transparent.svg b/inst/logos/svg/atom/nuclearff-bw-transparent.svg new file mode 100644 index 0000000..766de23 --- /dev/null +++ b/inst/logos/svg/atom/nuclearff-bw-transparent.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inst/logos/svg/atom/nuclearff-color-transparent.svg b/inst/logos/svg/atom/nuclearff-color-transparent.svg new file mode 100644 index 0000000..504482a --- /dev/null +++ b/inst/logos/svg/atom/nuclearff-color-transparent.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inst/logos/svg/logos/nuclearff-pink-blue-alt.svg b/inst/logos/svg/logos/nuclearff-pink-blue-alt.svg new file mode 100644 index 0000000..a9779b3 --- /dev/null +++ b/inst/logos/svg/logos/nuclearff-pink-blue-alt.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inst/logos/svg/logos/nuclearff-pink-blue-horizontal.svg b/inst/logos/svg/logos/nuclearff-pink-blue-horizontal.svg new file mode 100644 index 0000000..029fabf --- /dev/null +++ b/inst/logos/svg/logos/nuclearff-pink-blue-horizontal.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/inst/logos/svg/logos/nuclearff-pink-blue-vertical.svg b/inst/logos/svg/logos/nuclearff-pink-blue-vertical.svg new file mode 100644 index 0000000..3b75ec7 --- /dev/null +++ b/inst/logos/svg/logos/nuclearff-pink-blue-vertical.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/renv.lock b/renv.lock index b841a43..fc72600 100644 --- a/renv.lock +++ b/renv.lock @@ -178,7 +178,7 @@ "Package": "V8", "Version": "5.0.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "Rcpp", "curl", @@ -197,6 +197,16 @@ ], "Hash": "cad6cf7f1d5f6e906700b9d3e718c796" }, + "assertthat": { + "Package": "assertthat", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "tools" + ], + "Hash": "50c838a310445e954bc13f26f26a6ecf" + }, "backports": { "Package": "backports", "Version": "1.5.0", @@ -255,7 +265,7 @@ "Package": "bitops", "Version": "1.0-8", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Hash": "da69e6b6f8feebec0827205aad3fdbd8" }, "blob": { @@ -365,6 +375,18 @@ ], "Hash": "f61dbaec772ccd2e17705c1e872e9e7c" }, + "checkmate": { + "Package": "checkmate", + "Version": "2.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "backports", + "utils" + ], + "Hash": "0e14e01ce07e7c88fd25de6d4260d26b" + }, "chromote": { "Package": "chromote", "Version": "0.3.1", @@ -543,7 +565,7 @@ "Package": "data.table", "Version": "1.16.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "methods" @@ -787,6 +809,34 @@ ], "Hash": "daf90cda760f4481b2e38443bbd1030d" }, + "ffscrapr": { + "Package": "ffscrapr", + "Version": "1.4.8", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cachem", + "checkmate", + "cli", + "dplyr", + "glue", + "httr", + "jsonlite", + "lifecycle", + "magrittr", + "memoise", + "nflreadr", + "purrr", + "rappdirs", + "ratelimitr", + "rlang", + "stringr", + "tibble", + "tidyr" + ], + "Hash": "cc06d4e3d35b09266c9aa5242d78797f" + }, "fontawesome": { "Package": "fontawesome", "Version": "0.5.2", @@ -1028,14 +1078,14 @@ }, "glue": { "Package": "glue", - "Version": "1.7.0", + "Version": "1.8.0", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "e0b3a53876554bd45879e596cdb10a52" + "Hash": "5899f1eaa825580172bb56c08266f37c" }, "googledrive": { "Package": "googledrive", @@ -1114,7 +1164,7 @@ "Package": "gt", "Version": "0.11.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "base64enc", @@ -2038,6 +2088,16 @@ ], "Hash": "5e3c5dc0b071b21fa128676560dbe94d" }, + "ratelimitr": { + "Package": "ratelimitr", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "assertthat" + ], + "Hash": "4b0980d0fba83d6a50e2656cb51d7a5f" + }, "rcmdcheck": { "Package": "rcmdcheck", "Version": "1.4.0", @@ -2156,13 +2216,13 @@ }, "renv": { "Package": "renv", - "Version": "1.0.7", + "Version": "1.0.11", "Source": "Repository", - "Repository": "CRAN", + "Repository": "RSPM", "Requirements": [ "utils" ], - "Hash": "397b7b2a265bc5a7a06852524dabae20" + "Hash": "47623f66b4e80b3b0587bc5d7b309888" }, "reprex": { "Package": "reprex", @@ -2380,7 +2440,7 @@ "Package": "sf", "Version": "1.0-17", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "DBI", "R", @@ -2918,7 +2978,7 @@ "Package": "wk", "Version": "0.9.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], diff --git a/renv/activate.R b/renv/activate.R index d13f993..0eb5108 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,7 +2,7 @@ local({ # the requested version of renv - version <- "1.0.7" + version <- "1.0.11" attr(version, "sha") <- NULL # the project directory @@ -98,6 +98,66 @@ local({ unloadNamespace("renv") # load bootstrap tools + ansify <- function(text) { + if (renv_ansify_enabled()) + renv_ansify_enhanced(text) + else + renv_ansify_default(text) + } + + renv_ansify_enabled <- function() { + + override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA) + if (!is.na(override)) + return(as.logical(override)) + + pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA) + if (identical(pane, "build")) + return(FALSE) + + testthat <- Sys.getenv("TESTTHAT", unset = "false") + if (tolower(testthat) %in% "true") + return(FALSE) + + iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false") + if (tolower(iderun) %in% "false") + return(FALSE) + + TRUE + + } + + renv_ansify_default <- function(text) { + text + } + + renv_ansify_enhanced <- function(text) { + + # R help links + pattern <- "`\\?(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # runnable code + pattern <- "`(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # return ansified text + text + + } + + renv_ansify_init <- function() { + + envir <- renv_envir_self() + if (renv_ansify_enabled()) + assign("ansify", renv_ansify_enhanced, envir = envir) + else + assign("ansify", renv_ansify_default, envir = envir) + + } + `%||%` <- function(x, y) { if (is.null(x)) y else x } @@ -142,7 +202,10 @@ local({ # compute common indent indent <- regexpr("[^[:space:]]", lines) common <- min(setdiff(indent, -1L)) - leave - paste(substring(lines, common), collapse = "\n") + text <- paste(substring(lines, common), collapse = "\n") + + # substitute in ANSI links for executable renv code + ansify(text) } @@ -305,8 +368,11 @@ local({ quiet = TRUE ) - if ("headers" %in% names(formals(utils::download.file))) - args$headers <- renv_bootstrap_download_custom_headers(url) + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(url) + if (length(headers) && is.character(headers)) + args$headers <- headers + } do.call(utils::download.file, args) @@ -385,10 +451,21 @@ local({ for (type in types) { for (repos in renv_bootstrap_repos()) { + # build arguments for utils::available.packages() call + args <- list(type = type, repos = repos) + + # add custom headers if available -- note that + # utils::available.packages() will pass this to download.file() + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(repos) + if (length(headers) && is.character(headers)) + args$headers <- headers + } + # retrieve package database db <- tryCatch( as.data.frame( - utils::available.packages(type = type, repos = repos), + do.call(utils::available.packages, args), stringsAsFactors = FALSE ), error = identity @@ -470,6 +547,14 @@ local({ } + renv_bootstrap_github_token <- function() { + for (envvar in c("GITHUB_TOKEN", "GITHUB_PAT", "GH_TOKEN")) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(envval) + } + } + renv_bootstrap_download_github <- function(version) { enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") @@ -477,16 +562,16 @@ local({ return(FALSE) # prepare download options - pat <- Sys.getenv("GITHUB_PAT") - if (nzchar(Sys.which("curl")) && nzchar(pat)) { + token <- renv_bootstrap_github_token() + if (nzchar(Sys.which("curl")) && nzchar(token)) { fmt <- "--location --fail --header \"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "curl", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE) - } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + } else if (nzchar(Sys.which("wget")) && nzchar(token)) { fmt <- "--header=\"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "wget", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE)