Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- regs_tossups <- read_tsv("tossups.tsv")
- regs_games_played <- regs_tossups %>%
- filter(!is.na(team), packet != "S", !is.na(buzz_location_pct)) %>%
- distinct(team, packet) %>%
- count(team)
- # Change based on set categories
- regs_category_counts <- tribble(
- ~category, ~tu_count,
- "Literature", 4,
- "History", 4,
- "Science", 4,
- "Arts", 3,
- "RMPSS", 4,
- "Other", 1
- )
- regs_bpa <- regs_tossups %>%
- filter(!is.na(buzz_location_pct)) %>%
- left_join(regs_games_played %>% mutate(max_gets = 20*n)) %>%
- mutate(conv_flag = ifelse(buzz_value == "10", 1, 0),
- #Uncomment below line if set has powers
- #conv_flag = ifelse(buzz_value %in% c("15","10"), 1, 0),
- buzz_location_pct = ifelse(is.na(buzz_location_pct), 1, round(buzz_location_pct, 2)),
- buzz_location_pct = factor(buzz_location_pct, levels = seq(0,1,.01))) %>%
- group_by(player, team, max_gets, buzz_location_pct) %>%
- summarize(gets = sum(conv_flag)) %>%
- complete(nesting(player, team, max_gets), buzz_location_pct, fill = list(gets = 0)) %>%
- group_by(player, team) %>%
- mutate(cum_gets = cumsum(gets),
- conv_pct = cum_gets/max_gets,
- buzz_location_pct = buzz_location_pct %>% as.character() %>% as.numeric()) %>%
- ungroup() %>%
- mutate(player = paste0(player, " (", team, ")")) %>%
- group_by(player, team) %>%
- summarize(BPA = sum(conv_pct)) %>%
- arrange(-BPA)
Add Comment
Please, Sign In to add comment