Skip to content

Commit

Permalink
Merge pull request #45 from nflverse/standings
Browse files Browse the repository at this point in the history
Efficient Standings Implementation with data.table
  • Loading branch information
mrcaseb authored Oct 8, 2024
2 parents e745837 + e2d9664 commit e28c7ca
Show file tree
Hide file tree
Showing 28 changed files with 1,878 additions and 176 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ on:
branches: [main, master]
workflow_dispatch:

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
timeout-minutes: 20
timeout-minutes: 30

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
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'}
Expand All @@ -31,7 +33,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -49,3 +51,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
11 changes: 7 additions & 4 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
timeout-minutes: 30
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -40,7 +43,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: nflseedR
Title: Functions to Efficiently Simulate and Evaluate NFL Seasons
Version: 1.2.0.9001
Version: 1.2.0.9901
Authors@R: c(
person("Lee", "Sharpe", role = c("aut", "cph")),
person("Sebastian", "Carl", , "[email protected]", role = c("cre", "aut"))
person("Lee", "Sharpe", role = c("aut")),
person("Sebastian", "Carl", , "[email protected]", role = c("cre", "aut", "cph"))
)
Description: A set of functions to simulate National Football League
seasons including the sophisticated tie-breaking procedures.
Expand All @@ -29,11 +29,12 @@ Imports:
Suggests:
gt,
knitr,
nflplotR (>= 1.2.0),
rmarkdown,
scales,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
26 changes: 23 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,31 @@ export(compute_draft_order)
export(fmt_pct_special)
export(load_schedules)
export(load_sharpe_games)
export(nfl_standings)
export(simulate_nfl)
import(dplyr)
import(data.table)
import(gsubfn)
importFrom(cli,symbol)
importFrom(data.table,fread)
importFrom(data.table,rbindlist)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_rows)
importFrom(dplyr,case_when)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,inner_join)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,right_join)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,slice)
importFrom(dplyr,summarise)
importFrom(dplyr,summarize)
importFrom(dplyr,ungroup)
importFrom(furrr,furrr_options)
importFrom(furrr,future_map)
importFrom(future,plan)
Expand All @@ -22,4 +41,5 @@ importFrom(purrr,pluck)
importFrom(rlang,inform)
importFrom(stats,rnorm)
importFrom(tibble,is_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,pivot_longer)
4 changes: 2 additions & 2 deletions R/fmt_pct_special.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fmt_pct_special <- function(x){
if(!is.vector(x = x, mode = "numeric")){
cli::cli_abort("Argument {.arg x} has to be a numeric vector")
}
if(any(x > 1, na.rm = TRUE)){
cli::cli_abort("One or more values in {.arg x} are >1")
if(any(!x[!is.na(x)] %inrange% list(0L,1L))){
cli::cli_abort("One or more values in {.arg x} are outside the range between 0 and 1")
}
rlang::check_installed("scales", "to format numerical strings.")
# allocate prefix and accuracy vectors
Expand Down
22 changes: 11 additions & 11 deletions R/load_sharpe_games.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
# \item{alt_game_id}{This is a more human-readable ID. It consists of: The season, an underscore, the two-digit week number, an underscore, the away team, an underscore, the home team.}
#' \item{season}{The year of the NFL season. This represents the whole season, so regular season games that happen in January as well as playoff games will occur in the year after this number.}
#' \item{game_type}{What type of game? One of the following values:
#' \itemize{
#' \item{`REG`}{: a regular season game}
#' \item{`WC`}{: a wildcard playoff game}
#' \item{`DIV`}{: a divisional round playoff game}
#' \item{`CON`}{: a conference championship}
#' \item{`SB`}{: a Super Bowl}
#' \describe{
#' \item{`REG`}{a regular season game}
#' \item{`WC`}{a wildcard playoff game}
#' \item{`DIV`}{a divisional round playoff game}
#' \item{`CON`}{a conference championship}
#' \item{`SB`}{a Super Bowl}
#' }
#' }
#' \item{week}{The week of the NFL season the game occurs in. Please note that the `game_type` will differ for weeks >= 18 because of the season expansion in 2021. Please use `game_type` to filter for regular season or postseason.}
Expand Down Expand Up @@ -61,11 +61,11 @@
# \item{pff}{The id of the game issued by [Pro Football Focus](https://www.pff.com/)}
# \item{espn}{The id of the game issued by [ESPN](https://www.espn.com/)}
#' \item{roof}{What was the status of the stadium's roof? Will be one of the following values:
#' \itemize{
#' \item{`closed`}{: Stadium has a retractable roof which was closed}
#' \item{`dome`}{: An indoor stadium}
#' \item{`open`}{: Stadium has a retractable roof which was open}
#' \item{`outdoors`}{: An outdoor stadium}
#' \describe{
#' \item{`closed`}{Stadium has a retractable roof which was closed}
#' \item{`dome`}{An indoor stadium}
#' \item{`open`}{Stadium has a retractable roof which was open}
#' \item{`outdoors`}{An outdoor stadium}
#' }
#' }
#' \item{surface}{What type of ground the game was played on.}
Expand Down
8 changes: 5 additions & 3 deletions R/nflseedR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
# The following block is used by usethis to automatically manage
# roxygen namespace tags. Modify with care!
## usethis namespace: start
#' @import dplyr
#' @import data.table
#' @import gsubfn
#' @importFrom dplyr select mutate rename left_join inner_join n arrange group_by
#' @importFrom dplyr ungroup filter case_when summarize summarise pull right_join everything
#' @importFrom dplyr slice bind_rows row_number distinct
#' @importFrom cli symbol
#' @importFrom data.table rbindlist fread
#' @importFrom furrr future_map furrr_options
#' @importFrom future plan
#' @importFrom magrittr %>%
#' @importFrom progressr progressor
#' @importFrom purrr pluck
#' @importFrom rlang inform
#' @importFrom stats rnorm
#' @importFrom tibble is_tibble
#' @importFrom tibble is_tibble tibble
#' @importFrom tidyr pivot_longer
## usethis namespace: end
NULL
Loading

0 comments on commit e28c7ca

Please sign in to comment.