diff --git a/.github/workflows/pkgdown_test.yaml b/.github/workflows/pkgdown_test.yaml index d0feb2e..bc3ff53 100644 --- a/.github/workflows/pkgdown_test.yaml +++ b/.github/workflows/pkgdown_test.yaml @@ -20,46 +20,16 @@ jobs: - uses: r-lib/actions/setup-r@v1 with: use-public-rspm: true - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - name: Cache R packages - uses: actions/cache@v1 + - uses: r-lib/actions/setup-r-dependencies@v1 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages(c("pkgdown", "roxygen2")) - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . + extra-packages: pkgdown, roxygen2 + needs: website - name: Deploy package run: | git config --local user.email "actions@github.com" git config --local user.name "GitHub Actions" Rscript -e 'roxygen2::roxygenise()' - Rscript -e 'pkgdown::deploy_to_branch(new_process = TRUE, branch = "gh-pages-test")' - -# - uses: r-lib/actions/setup-r-dependencies@v1 -# with: -# extra-packages: pkgdown -# needs: website - -# - name: Deploy package -# run: | -# git config --local user.name "$GITHUB_ACTOR" -# git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" -# Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, branch = "gh-pages-test")' - + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, branch = "gh-pages-test")' diff --git a/DESCRIPTION b/DESCRIPTION index 08c4b97..be80fc6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,9 +15,6 @@ LazyData: true Imports: dplyr, forcats, - ggimage, - ggplot2, - ggrepel, glue, magrittr, nflfastR, diff --git a/R/import.R b/R/import.R index ae17b8f..85968a3 100644 --- a/R/import.R +++ b/R/import.R @@ -34,9 +34,9 @@ import_punts <- function(years, local = FALSE, path = NULL) { } #' Import play-by-play data -#' @description Grab all play-by-play data, not just punts. This function pulls data directly from the \code{nflfastR-data} repo, and -#' is purely a wrapper for ease of use. -#' @param years A year or range of years between 1999 and 2020, inclusive +#' @description DEPRECATED: Grab all play-by-play data, not just punts, from the \code{nflfastR-data} repo. This will be much slower than +#' using the \code{nflfastR::load_pbp()} or \code{nflfastR::update_pbp()} functions. +#' @param years A year or range of years between 1999 and 2021, inclusive #' @return A tibble \code{pbp} containing play-by-play data for the specified years #' @examples #' \dontrun{ diff --git a/R/mini2.R b/R/mini2.R index be38142..ea9dcb0 100644 --- a/R/mini2.R +++ b/R/mini2.R @@ -99,15 +99,24 @@ custom_summary <- function(data, ...) { SHARP_RERUN_OF = mean(SHARP_RERUN_OF, na.rm = TRUE), SHARP_RERUN_PD = mean(SHARP_RERUN_PD, na.rm = TRUE), ..., - team = getmode_local(posteam), - team_logo_espn = getmode_local(team_logo_espn), - team_color = getmode_local(team_color), - team_color2 = getmode_local(team_color2), + team = puntr::getmode(posteam), + team_logo_espn = puntr::getmode(team_logo_espn), + team_color = puntr::getmode(team_color), + team_color2 = puntr::getmode(team_color2), ) return(.summary) } - -getmode_local <- function(v) { - uniqv <- unique(v) - uniqv[which.max(tabulate(match(v, uniqv)))] +#' Find the mode of a column +#' @description Hilariously, R does not have a built-in method for finding the mode of a column. \code{puntr} has included an internal +#' helper function for this purpose for a while, and now it can be yours too! +#' @param column The dataframe column (or any other list) from which you would like to extract the most frequently occuring item +#' @return The mode of \code{column} +#' @examples +#' \dontrun{ +#' players_most_common_team <- getmode(punts_by_punter$posteam) +#' } +#' @export +getmode <- function(column) { + uniqv <- unique(column) + uniqv[which.max(tabulate(match(column, uniqv)))] } diff --git a/_pkgdown.yml b/_pkgdown.yml index 940089f..5eec0d1 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -22,6 +22,9 @@ reference: desc: Turn a play-by-play dataframe into a dataframe summarizing player stats - contents: - starts_with("by_punter") +- title: Miscellaneous + contents: + - getmode - title: Deprecated - contents: - starts_with("create")