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

Add lateral_return_yards variable? #355

Open
TheMathNinja opened this issue Sep 2, 2022 · 2 comments
Open

Add lateral_return_yards variable? #355

TheMathNinja opened this issue Sep 2, 2022 · 2 comments

Comments

@TheMathNinja
Copy link
Contributor

  1. **Have you installed the latest development version of the package(s) in question? **
    Yes

  2. Describe the bug
    return_yards is returning the wrong number in the pbp df.

  3. Reprex

slay_bug <- nflfastR::load_pbp(2021) %>%
  filter(week == 6,
         interception == 1,
         defteam == "PHI")
  1. Expected Behaviour
    return_yards should be 6. Anthony Harris should get 2, then he laterals to Darius Slay who gets 4 more. But return_yards shows 4, only counting the yards post-lateral.

  2. nflverse_sitrep()

sitrep
# nflverse_sitrep() goes here
  1. Screenshots
  1. Additional context
@TheMathNinja TheMathNinja added the bug Something isn't working label Sep 2, 2022
@mrcaseb
Copy link
Member

mrcaseb commented Sep 2, 2022

This is actually not a bug in return yards as it is exactly the same like for rushing or receiving yards when laterals happen in a play. We could catch this for plays with one lateral (!) by adding a lateral_return_yards variable for stat IDs 27 and 28

Here

row$return_yards <- play_stats$yards[index]

and here
row$return_yards <- play_stats$yards[index]

Analog to stat IDs 23 and 24 for example

row$lateral_receiving_yards <- play_stats$yards[index]

row$lateral_receiving_yards <- play_stats$yards[index]

As soon as multiple laterals with non 0 yards happen in a play there is no chance to see them in either of these variables. That would be very inefficient in a tidy data structure.

@mrcaseb mrcaseb added Feature Request and removed bug Something isn't working labels Sep 2, 2022
@mrcaseb mrcaseb changed the title return_yards bug in pbp Add lateral_return_yards variable? Sep 2, 2022
@mrcaseb
Copy link
Member

mrcaseb commented Sep 2, 2022

For calculate_player_stats() we catch this by loading yards from a separate file that is hosting plays with multiple laterals, which are very rare but happen.

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

No branches or pull requests

2 participants