Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Lost fumble T.Law Week 1 2023 nflfastR #429

Closed
2 tasks done
RileyJohnson22 opened this issue Sep 13, 2023 · 1 comment · Fixed by #431
Closed
2 tasks done

[BUG] Lost fumble T.Law Week 1 2023 nflfastR #429

RileyJohnson22 opened this issue Sep 13, 2023 · 1 comment · Fixed by #431

Comments

@RileyJohnson22
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Have you installed the latest development version of the package(s) in question?

  • I have installed the latest development version of the package.

What version of the package do you have?

4.5.1

Describe the bug

In the current code for sack_fumbles_lost in nflfastr::calculate_player_stats(), it calculates:
sack_fumbles_lost = [sum](.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$passer_player_id)
I would suggest a check in here of whether fumble_recovery_1_team is different than the player who fumbled in here.
.data$fumbled_1_team!=.data$fumble_recovery_1_team
Statistically, the lost fumble should only be charged to Bigsby.
This is of course not a common occurrence but could be applied to rushing fumbles and receiving fumbles as well

Reprex

load_pbp(2023) %>%
  filter(season_type=="REG") %>%
  calculate_player_stats(weekly=TRUE) %>%
  filter(player_display_name=="Trevor Lawrence")

Expected Behavior

I would expect 0 for sack_fumbles_lost

nflverse_sitrep

> nflverse_sitrep()
ℹ You've asked for the packages nflseedR, nfl4th, nflplotR, and nflverse which are not installed. 
They are skipped.
── System Info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• R version 4.3.0 (2023-04-21 ucrt)   • Running under: Windows 10 x64 (build 19045)
── nflverse Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────
• nflreadr (1.3.2)
• nflfastR (4.5.1)
── nflverse Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────
No options set for nflreadr and nflfastR
── nflverse Dependencies ──────────────────────────────────────────────────────────────────────────────────────────────────────
• cachem      (1.0.8)   • hms        (1.1.3)    • purrr      (1.0.1)    
• cli         (3.6.1)   • janitor    (2.2.0)    • R6         (2.5.1)    
• codetools   (0.2-19)  • jsonlite   (1.8.5)    • rappdirs   (0.3.3)    
• cpp11       (0.4.3)   • lattice    (0.21-8)   • rlang      (1.1.1)    
• curl        (5.0.1)   • lifecycle  (1.0.3)    • snakecase  (0.11.0)   
• data.table  (1.14.8)  • listenv    (0.9.0)    • stringi    (1.7.12)   
• digest      (0.6.31)  • lubridate  (1.9.2)    • stringr    (1.5.0)    
• dplyr       (1.1.2)   • magrittr   (2.0.3)    • tibble     (3.2.1)    
• fansi       (1.0.4)   • Matrix     (1.5-4)    • tidyr      (1.3.0)    
• fastmap     (1.1.1)   • memoise    (2.0.1)    • tidyselect (1.2.0)    
• fastrmodels (1.0.2)   • mgcv       (1.8-42)   • timechange (0.2.0)    
• furrr       (0.3.1)   • nlme       (3.1-162)  • utf8       (1.2.3)    
• future      (1.33.0)  • parallelly (1.36.0)   • vctrs      (0.6.2)    
• generics    (0.1.3)   • pillar     (1.9.0)    • withr      (2.5.0)    
• globals     (0.16.2)  • pkgconfig  (2.0.3)    • xgboost    (1.7.5.1)  
• glue        (1.6.2)   • progressr  (0.14.0)

Screenshots

No response

Additional context

No response

@mrcaseb
Copy link
Member

mrcaseb commented Sep 15, 2023

Fixed in #431

nflreadr::load_pbp() |> 
  nflfastR::calculate_player_stats(weekly = TRUE) |> 
  dplyr::filter(player_name == "T.Lawrence") |> 
  dplyr::select(
    player_id, player_name, week, opponent_team, tidyselect::contains("fumble")
  ) |> 
  dplyr::glimpse()
#> Rows: 1
#> Columns: 10
#> $ player_id              <chr> "00-0036971"
#> $ player_name            <chr> "T.Lawrence"
#> $ week                   <int> 1
#> $ opponent_team          <chr> "IND"
#> $ sack_fumbles           <int> 1
#> $ sack_fumbles_lost      <int> 0
#> $ rushing_fumbles        <dbl> 0
#> $ rushing_fumbles_lost   <dbl> 0
#> $ receiving_fumbles      <dbl> 0
#> $ receiving_fumbles_lost <dbl> 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants