Giter Club home page Giter Club logo

Comments (2)

akeaswaran avatar akeaswaran commented on June 15, 2024

For anyone that picks this up, I believe drive_pts is coming from the new_drive_pts column here:

cfbfastR/R/cfbd_pbp_data.R

Lines 1407 to 1445 in 4c02a4a

new_drive_pts = dplyr::case_when(
.data$downs_turnover == 1 ~ 0,
.data$play_type == "Punt" ~ 0,
.data$play_type == "Blocked Punt (Safety)" & .data$safety == 1 ~ -2,
.data$play_type == "Punt (Safety)" ~ -2,
.data$play_type == "Blocked Punt" & .data$safety == 1 ~ -2,
.data$play_type == "Blocked Punt" ~ 0,
.data$play_type == "Blocked Punt Touchdown" ~ -7,
.data$play_type == "Punt Touchdown" ~ 7,
.data$play_type == "Punt Team Fumble Recovery Touchdown" ~ 7,
.data$play_type == "Punt Return Touchdown" ~ -7,
.data$play_type == "Fumble Recovery (Opponent) Touchdown" ~ -7,
.data$play_type == "Fumble Return Touchdown" ~ -7,
.data$play_type == "Fumble Recovery (Opponent)" ~ 0,
.data$play_type == "Fumble Recovery (Own) Touchdown" ~ 7,
.data$play_type == "Interception Return Touchdown" ~ -7,
.data$play_type == "Interception Return" ~ 0,
.data$play_type == "Sack Touchdown" ~ -7,
.data$play_type == "Safety" & .data$kickoff_play == 0 ~ -2,
.data$play_type == "Kickoff Team Fumble Recovery Touchdown" ~ -7,
.data$play_type == "Kickoff (Safety)" & .data$kickoff_safety == 1 ~ -2,
.data$play_type == "Kickoff" & .data$kickoff_safety == 1 ~ -2,
.data$play_type == "Penalty (Safety)" ~ -2,
.data$play_type == "Passing Touchdown" ~ 7,
.data$play_type == "Pass Reception Touchdown" ~ 7,
.data$play_type == "Rushing Touchdown" ~ 7,
.data$play_type == "Field Goal Good" ~ 3,
.data$play_type == "Field Goal Missed" ~ 0,
.data$play_type == "Missed Field Goal Return" ~ 0,
.data$play_type == "Blocked Field Goal Touchdown" ~ -7,
.data$play_type == "Missed Field Goal Return Touchdown" ~ -7,
.data$play_type == "Blocked Field Goal" ~ 0,
.data$play_type == "Uncategorized Touchdown" ~ 7,
.data$play_type == "End of Half" ~ 0,
.data$play_type == "End of Game" ~ 0,
.data$scoring_play == 0 & .data$TimeSecsRem == 0 & period %in% c(2, 4) ~ 0,
TRUE ~ 0
),
new_drive_pts = ifelse(.data$new_drive_pts == 0, NA_integer_, .data$new_drive_pts),

You'd have to grab the result of the PAT play via a lead or via the play_text and adjust those values accordingly.

from cfbfastr.

Kazink36 avatar Kazink36 commented on June 15, 2024

Looks like drive_pts is actually coming from here based on the drives endpoint form cfbd:

cfbfastR/R/cfbd_pbp_data.R

Lines 2041 to 2059 in 4c02a4a

pts_drive = dplyr::case_when(
.data$drive_result == "TD" ~ 7,
stringr::str_detect(.data$drive_result, "SF") ~ -2,
.data$drive_result == "FG GOOD" ~ 3,
.data$drive_result == "FG" ~ 3,
.data$drive_result == "MISSED FG TD" ~ -7,
.data$drive_result == "KICKOFF RETURN TD" ~ -7,
.data$drive_result == "END OF HALF TD" ~ 7,
.data$drive_result == "END OF GAME TD" ~ 7,
.data$drive_result == "PUNT RETURN TD" ~ -7,
.data$drive_result == "PUNT TD" ~ -7,
.data$drive_result == "INT TD" ~ -7,
.data$drive_result == "INT RETURN TOUCH" ~ -7,
.data$drive_result == "FUMBLE RETURN TD" ~ -7,
.data$drive_result == "FUMBLE TD" ~ -7,
.data$drive_result == "DOWNS TD" ~ -7,
stringr::str_detect(.data$drive_result, "TD") ~ 7,
TRUE ~ 0
),

The drive endpoint also includes the starting and ending scores for both offense and defense which could (and probably should?) be used to generate the drive points instead. I'm just thinking about what makes sense when both teams score points (like the defensive conversion) and I think your suggestion of -5, -4, 4, and 5 makes sense as a column showing the change in score differential

from cfbfastr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.