Skip to content

Commit

Permalink
Merge branch 'test_branch' of https://github.com/Puntalytics/puntr in…
Browse files Browse the repository at this point in the history
…to test_branch
  • Loading branch information
dennisbrookner committed Aug 16, 2024
2 parents c3f6cc4 + 8ba9c48 commit 100ecea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 48 deletions.
38 changes: 4 additions & 34 deletions .github/workflows/pkgdown_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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 "[email protected]"
# 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")'
3 changes: 0 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ LazyData: true
Imports:
dplyr,
forcats,
ggimage,
ggplot2,
ggrepel,
glue,
magrittr,
nflfastR,
Expand Down
6 changes: 3 additions & 3 deletions R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
25 changes: 17 additions & 8 deletions R/mini2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))]
}
3 changes: 3 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 100ecea

Please sign in to comment.