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 variable for "ball handler" (rusher or receiver) #121

Closed
mrcaseb opened this issue Oct 9, 2020 · 6 comments · Fixed by #177
Closed

Add variable for "ball handler" (rusher or receiver) #121

mrcaseb opened this issue Oct 9, 2020 · 6 comments · Fixed by #177
Labels
Feature Request Offseason to-do Something to add when season is over

Comments

@mrcaseb
Copy link
Member

mrcaseb commented Oct 9, 2020

I got this question via twitter if there is a variable or an easy way to get the "ball handler" (rusher or receiver) on a play. This would be the rushing/receiving counterpart to name and id and I see why some people could be intereted in it (epsecially fantasy guys).

I think we should add this to clean_pbp() during the next off-season.

Something like

pbp %>% 
  dplyr::mutate(
    handler = case_when(
      !is.na(rusher) ~ rusher,
      is.na(rusher) & !is.na(receiver) ~ receiver,
      TRUE ~ passer
    ),
    handler_id = case_when(
      !is.na(rusher_id) ~ rusher_id,
      is.na(rusher_id) & !is.na(receiver_id) ~ receiver_id,
      TRUE ~ passer_id
    )
  )
@guga31bb guga31bb added the Offseason to-do Something to add when season is over label Oct 9, 2020
@guga31bb
Copy link
Member

guga31bb commented Feb 6, 2021

Putting this here so I don't forget but I think action_player is my favorite https://twitter.com/benbbaldwin/status/1358139028500062209

@guga31bb
Copy link
Member

guga31bb commented Feb 6, 2021

For discussion: do we want to use the NFL-provided ones (eg rusher_player_name and rusher_player_id) or the cleaned ones (rusher and rusher_id) for this? If this is going to be primarily used for fantasy purposes, I would think the former since that's how to calculate the official stats (because it doesn't include plays negated by penalty).

@mrcaseb
Copy link
Member Author

mrcaseb commented Feb 6, 2021

For discussion: do we want to use the NFL-provided ones (eg rusher_player_name and rusher_player_id) or the cleaned ones (rusher and rusher_id) for this? If this is going to be primarily used for fantasy purposes, I would think the former since that's how to calculate the official stats (because it doesn't include plays negated by penalty).

I just wanted to ask this exact question. My initial idea with handler was that we do both in the same pattern. handler (including penalties) and handler_player_name excluding penalties.

I kind of like the idea of having both.

@mrcaseb
Copy link
Member Author

mrcaseb commented Feb 6, 2021

Putting this here so I don't forget but I think action_player is my favorite https://twitter.com/benbbaldwin/status/1358139028500062209

How about carrier, carrier_id and carrier_player_name, carrier_player_id?

@guga31bb
Copy link
Member

guga31bb commented Feb 6, 2021

I think carrier makes it sound too much like rushing plays only (i.e. it's not obvious that it includes WRs on incomplete passes).

But having both sounds good to me whatever we decide on the name

@guga31bb
Copy link
Member

guga31bb commented Feb 11, 2021

Here is my current vote

      dplyr::mutate(
        fantasy_player_name = case_when(
          !is.na(.data$rusher_player_name) ~ .data$rusher_player_name,
          is.na(.data$rusher_player_name) & !is.na(.data$receiver_player_name) ~ .data$receiver_player_name,
          TRUE ~ NA_character_
        ),
        fantasy_player_id = case_when(
          !is.na(.data$rusher_player_id) ~ .data$rusher_player_id,
          is.na(.data$rusher_player_id) & !is.na(.data$receiver_player_id) ~ .data$receiver_player_id,
          TRUE ~ NA_character_
        ),
        fantasy = case_when(
          !is.na(.data$rusher) ~ .data$rusher,
          is.na(.data$rusher) & !is.na(.data$receiver) ~ .data$receiver,
          TRUE ~ NA_character_
        ),
        fantasy_id = case_when(
          !is.na(.data$rusher_id) ~ .data$rusher_id,
          is.na(.data$rusher_id) & !is.na(.data$receiver_id) ~ .data$receiver_id,
          TRUE ~ NA_character_
        )
      )

I started with action instead of fantasy but just having action itself as a column feels weird.

I think I just need to add this to clean_pbp() and add fantasy_id to the any_of in helper_decode_player_ids.R

@guga31bb guga31bb linked a pull request Feb 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Offseason to-do Something to add when season is over
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants