-
Notifications
You must be signed in to change notification settings - Fork 50
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
Feature Request downed_by_player_*
#255
Labels
Comments
Example code how to do this. I doubt we will add that as the missing player IDs are a problem. There is definitely no stat ID for downed punts or onside kicks library(tidyverse)
nflreadr::load_pbp(2020) |>
filter(special == 1, str_detect(desc, "downed by")) |>
mutate(
downed_by = str_extract(desc, "(?<=downed by )[:graph:]+(?=\\.)"),
downed_by_team = str_extract(downed_by, "[:upper:]{2,3}(?=-?)"),
downed_by_player_name = str_extract(downed_by, "(?<=[:digit:]-)[:graph:]+"),
downed_by_jersey_number = str_extract(downed_by, "(?<=-)[:digit:]{1,2}(?=-)")
) |>
select(play_type, desc, starts_with("downed_by_"))
#> # A tibble: 256 x 5
#> play_type desc downed_by_team downed_by_player_n~ downed_by_jersey_nu~
#> <chr> <chr> <chr> <chr> <chr>
#> 1 punt (5:51) 4-A.Lee punts 41 yards to SF 7, Center-46-A.Brewer, downed by ARI-16-T.Sherfield. ARI T.Sherfield 16
#> 2 punt (14:13) 3-J.Fox punts 54 yards to CHI 12, Center-48-D.Muhlbach, downed by DET-52-C.Jones. DET C.Jones 52
#> 3 punt (8:37) 16-P.O'Donnell punts 38 yards to DET 33, Center-48-P.Scales, downed by CHI-50-B.Mingo. CHI B.Mingo 50
#> 4 punt (8:51) 7-J.Gillan punts 59 yards to BAL 1, Center-47-C.Hughlett, downed by CLE-20-T.Thomas. CLE T.Thomas 20
#> 5 punt (:51) 4-S.Koch punts 37 yards to CLE 08, Center-46-M.Cox, downed by BAL-86-N.Boyle. BAL N.Boyle 86
#> 6 punt (1:22) 5-T.Townsend punts 38 yards to HOU 5, Center-41-J.Winchester, downed by KC-13-B.Pringle. KC B.Pringle 13
#> 7 punt (13:14) 9-L.Cooke punts 53 yards to IND 29, Center-49-B.Miller, downed by JAX-27-C.Claybrooks. JAX C.Claybrooks 27
#> 8 punt (8:20) 7-J.Bailey punts 40 yards to MIA 11, Center-49-J.Cardona, downed by NE-22-C.Davis. NE C.Davis 22
#> 9 punt (9:07) 5-T.Way punts 47 yards to PHI 4, Center-57-N.Sundberg, downed by WAS-89-C.Sims. WAS C.Sims 89
#> 10 punt (1:55) 5-T.Way punts 43 yards to PHI 28, Center-57-N.Sundberg, downed by WAS-47-K.Hudson. WAS K.Hudson 47
#> 11 punt (1:42) 9-R.Dixon punts 32 yards to PIT 22, Center-58-C.Kreiter, downed by NYG-58-C.Kreiter. NYG C.Kreiter 58
#> 12 punt (:22) 6-T.Morstead punts 50 yards to TB 22, Center-49-Z.Wood, downed by NO-34-J.Hardee. NO J.Hardee 34
#> 13 punt (10:26) 2-M.Haack punts 63 yards to BUF 3, Center-50-B.Ferguson, downed by MIA-86-M.Hollins. MIA M.Hollins 86
#> 14 punt (8:53) 2-M.Haack punts 51 yards to BUF 6, Center-50-B.Ferguson, downed by MIA-86-M.Hollins. MIA M.Hollins 86
#> 15 punt (5:38) 10-K.Huber punts 48 yards to CLE 37, Center-46-C.Harris, downed by CIN-27-T.Brown. CIN T.Brown 27
#> 16 punt (13:04) 6-B.Kern punts 34 yards to JAX 6, Center-48-B.Brinkley, downed by TEN-30-C.Milton. TEN C.Milton 30
#> 17 punt (13:39) 1-T.Long punts 31 yards to KC 27, Center-45-C.Mazza, downed by LAC-45-C.Mazza. LAC C.Mazza 45
#> 18 punt (6:09) 8-R.Sanchez punts 39 yards to MIN 2, Center-46-L.Rhodes, downed by IND-30-G.Odum. IND G.Odum 30
#> 19 punt (11:19) 8-R.Sanchez punts 48 yards to MIN 24, Center-46-L.Rhodes, downed by IND-20-J.Wilkins. IND J.Wilkins 20
#> 20 punt (8:58) 7-J.Bailey punts 57 yards to SEA 25, Center-49-J.Cardona, downed by NE-29-J.Bethel. NE J.Bethel 29
#> 21 punt (:28) 4-M.Dickson punts 54 yards to NE 2, Center-69-T.Ott, downed by SEA-44-N.Bellore. SEA N.Bellore 44
#> 22 punt (3:55) 9-R.Dixon punts 62 yards to CHI 8, Center-58-C.Kreiter, downed by NYG-18-C.Board. NYG C.Board 18
#> 23 punt (10:19) 16-P.O'Donnell punts 51 yards to NYG 14, Center-48-P.Scales, downed by CHI. CHI <NA> <NA>
#> 24 punt (4:04) 16-P.O'Donnell punts 33 yards to NYG 5, Center-48-P.Scales, downed by CHI-27-S.McManis. CHI S.McManis 27
#> 25 punt (6:04) 5-T.Way punts 30 yards to ARI 10, Center-57-N.Sundberg, downed by WAS-87-J.Sprinkle. WAS J.Sprinkle 87
#> 26 punt (12:52) 1-T.Long punts 47 yards to CAR 12, Center-45-C.Mazza, downed by LAC-28-B.Facyson. LAC B.Facyson 28
#> 27 punt (1:55) 3-J.Charlton punts 40 yards to end zone, Center-44-J.Jansen, Touchback. The Replay Official reviewed the touchback ruling, ~ CAR J.Jansen 44
#> 28 punt (7:03) 10-K.Huber punts 39 yards to PHI 9, Center-46-C.Harris, downed by CIN-12-A.Erickson. CIN A.Erickson 12
#> 29 punt (10:05) 4-M.Dickson punts 47 yards to DAL 6, Center-69-T.Ott, downed by SEA-69-T.Ott. SEA T.Ott 69
#> 30 punt (9:54) 3-J.Fox punts 60 yards to ARI 14, Center-48-D.Muhlbach, downed by DET. DET <NA> <NA>
#> # ... with 226 more rows Created on 2021-08-18 by the reprex package (v2.0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be possible to add a
downed_by_player_name
column as requested in this thread.However, we would be missing the player id in that case which wouldn't fit in our normal system.
Maybe there is a stat id?
The text was updated successfully, but these errors were encountered: