Skip to content

Instantly share code, notes, and snippets.

@andrewbtran
Created April 29, 2019 14:32
Show Gist options
  • Save andrewbtran/4bf3d8dd7a0f443f4888a31eaa7fff1b to your computer and use it in GitHub Desktop.
Save andrewbtran/4bf3d8dd7a0f443f4888a31eaa7fff1b to your computer and use it in GitHub Desktop.
Game of Thrones death pool (week 3 results)
library(tidyverse)
responses <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vT7yj6UE0S08spLamewjnZH1vbOCqobyRSEao5I535XvgO9VeM_fwe-P84_9oiPAuQsfd5rYyncNuax/pub?output=csv")
week3 <- data.frame(c("Theon Greyjoy",
"Melisandre",
"Jorah Mormont",
"Edd Tollett",
"Lyanna Mormont",
"Beric Dondarrion (can select multiple eps for death)
"))
colnames(week3) <- "category"
week3$killed <- "yes"
responses <- responses %>%
select(-Timestamp, -`Email Address`) %>%
gather(2:31, key="category", value="detail") %>%
mutate(category=str_sub(category, 36, -2))
week3_guesses <- responses %>% filter(detail=="Dies in Episode 3")
week3_guesses <- left_join(week3_guesses, week3)
week3_guesses <- left_join(week3_guesses, survivor_responses)
week3_guesses <- week3_guesses %>%
mutate(points=case_when(
killed=="yes" ~ 2,
TRUE ~ -1
))
points <- week3_guesses %>%
group_by(`Your name`) %>%
summarize(points=sum(points)) %>%
arrange(desc(points))
## for future weeks
survivor_responses <- responses %>% filter(detail=="Survives!") %>%
mutate(survive_guess="Y") %>%
select(-detail)
survivor_responses <- left_join(survivor_responses, week3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment