-
Notifications
You must be signed in to change notification settings - Fork 51
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
Multiple Penalty Infractions on the Same Play Obscure the True Penalty Count and True Penalty Yardage #220
Comments
When do you guys usually release a new version to CRAN? I am eager to try out the fixes that have just been rolled out. Is it also true that some of the same guys have created a thing called nflseedR? When will that make it to CRAN? Thanks for all of the awesome! |
There is no typical timeline for CRAN release. But we plan to bring an update in the next days.
That's true. Lee Sharpe and I developed nflseedR. We wanted to give the users the chance to play with it and find bugs prior to a CRAN release. Installation is analogue to the above
|
I am going to leave myself a note here and hope that maybe this helps others out while we wait for the nflfastR creators to work their magic. Heck, maybe even the creators will benefit from this a little bit. So, first things first. Let's run a line of code that will locate all of the plays with double penalties. The second boolean test is to eliminate all of the plays with successful replay reviews that cause the NFL pbp to repeat the play text, which will duplicate the PENALTY notification.
So, now let's just call the third one Then let's extract all of the penalties from this play!
Now we can see that Hopkins committed two penalties on this play. If he (or someone else) committed more, they would also be extracted. Now we can handle each one like we handle all of the single penalty cases. As long as I am right in that the NFL pbp will always say "PENALTY...enforced" for each accepted/enforced penalty, this should work. I, of course, will have to hope that a successful replay review will never coincide with a play with multiple penalties. |
Does RStudio know how to update GitHub loaded packages when I hit the "Update" button? If you already have the CRAN version installed of a package, will the installation go wrong? Would I have to/want to remove the current nflfastR already installed? I was waiting for the official release since I was thinking that RStudio would do a better job of updating packages if they are CRAN releases. I can't wait to try out nflseedR! It was always something I wanted to write for myself, but it seemed too ambitious. I am glad some professionals got around to writing something. 👍 |
So, if we want to patch the pbp database for now while the cure is on the way, we can run this little bit of code. If the database is called
This is a patch and not a fix since it works in the case when only one team committed accepted penalties on a play. This will do for now because most cases when both teams commit penalties results in offsetting penalties and no penalty yards. I have only checked 2020 so far to validate this code. If you run the patch and then you check for penalty totals in 2020:
We can count the yards, too.
This matches data from ESPN. Funny enough, no two sources seem to agree on penalties, so I picked ESPN to match. If anyone can improve on this, please do. It could use some work. |
Uh, oh! We have a double penalty from different teams that do not offset. I was hoping this wouldn't happen before NFLFastR got around to implementing separate columns for home and away team penalties.
Because I sure hope NFLFastR can get around to this issue soon. |
We had another play in Week 4 2022. The first play of the fourth quarter between Arizona and Carolina saw both teams with penalties that did not offset.
Hopefully we can address this soon in a new release of NFLFastR. |
We always welcome pull requests, but if this would require adding fields, it would not be implemented until the offseason. |
There won't be a fix in pbp for multiple penalties in one play. But the new function |
Consider the following three plays from 2020. They all involve multiple penalty infractions on the same play.
play_id | game_id | desc | penalty_team | penalty_yards | penalty_player_name
2800 | 2020_15_TB_ATL | (1:45) 12-T.Brady pass incomplete short right to 13-M.Evans. PENALTY on ATL-24-A.Terrell, Defensive Pass Interference, 13 yards, enforced at ATL 45 - No Play. PENALTY on ATL-24-A.Terrell, Face Mask (15 Yards), 15 yards, enforced between downs. | ATL | 15 | A.Terrell
1686 | 2020_15_LAC_LV | (14:55) 64-C.Toner reported in as eligible. 10-J.Herbert pass incomplete short right to 15-J.Guyton. PENALTY on LV-27-T.Mullen, Defensive Pass Interference, 13 yards, enforced at LAC 25 - No Play. PENALTY on LV-27-T.Mullen, Face Mask (15 Yards), 15 yards, enforced between downs. | LV | 15 | T.Mullen
2559 | 2020_17_ARI_LA | (5:21) (Shotgun) 15-C.Streveler pass deep middle to 10-D.Hopkins to LA 10 for 40 yards (43-J.Johnson III). PENALTY on ARI-10-D.Hopkins, Offensive Pass Interference, 10 yards, enforced at 50 - No Play. PENALTY on ARI-10-D.Hopkins, Unsportsmanlike Conduct, 15 yards, enforced between downs. | ARI | 15 | D.Hopkins
The first case shows 28 yards of penalties on ATL, but only 15 yards are shown in the "penalty_yards" column. The second shows Mr. Mullen committed 28 yards of penalties on behalf on LV, but only 15 yards are shown in "penalty_yards". The third shows Nuke Hopkins with 25 yards of penalties, but "penalty_yards" only shows 15 yards.
These occurrences are rare, but when they happen, they make counting penalties and penalty yards in a game difficult. I am using the "penalty_yards" field and a filter on "penalty_team" to sum up the penalty yardage assessed to a team. This means my penalty yardage totals for these three games comes up short. I use the nrow() function and a filter on "penalty_team" to count the number of penalties on a team. This means my penalty counts come up short, as well, since in these cases more than one penalty is represented by each row.
Might I humbly suggest a set of fields called home_num_penalties, home_penalty_yardage, away_num_penalties, and away_penalty_yardage (or something similar) to make obtaining penalty counts and penalty yardage per team easier? Or if a way to accomplish this task with the current data set is possible, I would love to hear about it.
Thanks so much for your consideration, and for providing the best NFL data collection tool. Have a wonderful day!
The text was updated successfully, but these errors were encountered: