-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebcast_coverage.Rmd
146 lines (123 loc) · 3.26 KB
/
webcast_coverage.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
title: "TBA Webcast Coverage"
author: "Greg Marra"
date: "11/4/2018"
output: github_document
---
Many people come to The Blue Alliance to watch webcasts of FIRST Robotics Competition events. How is our coverage ofwebcasts and match videos trending over time?
# Webcasts
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(skimr)
source("get_tba_data.R")
get_size <- function(thing) {
if ( class(thing) == "list" ) {
return(thing %>% length)
} else if ( class(thing) == "data.frame") {
return(thing %>% nrow)
} else {
return(FALSE)
}
}
years <- c(
2011,
2012,
2013,
2014,
2015,
2016,
2017,
2018)
events <- years %>%
map(~ getEvents(.x)) %>%
bind_rows() %>%
mutate(
has_webcast = map_int(webcasts, get_size) > 0,
official = !event_type_string %in% c("Preseason", "Offseason")
) %>%
mutate(
official = factor(.$official, levels=c(TRUE, FALSE)) # put official events before unofficial ones
)
matches <- map2(events$year,
events$event_code,
~ getEventMatches(.x, .y)
) %>%
bind_rows()
matches <- matches %>%
left_join(events, by = c("event_key" = "key")) %>%
mutate(
has_video = map_int(videos, get_size) > 0
)
```
### Event Webcast Coverage
```{r webcast_coverage_bar_chart}
events %>%
ggplot(aes(x = year,
fill = has_webcast)) +
geom_bar() +
facet_grid(. ~ official, labeller = label_both) +
labs(
title = "Event Webcast Coverage",
subtitle = "Webcast coverage is growing over time",
x = "Year",
y = "Events",
fill = "Has Webcast"
)
```
### As Ratios
While nearly all official events are webcast, we see that the trend over time is for more and more unofficial events to also run webcasts.
```{r webcast_coverage_pct}
events %>%
group_by(year, official) %>%
summarize(
n_events = n(),
n_events_w_webcast = sum(has_webcast),
pct_events_w_webcast = mean(has_webcast)
) %>%
ggplot(aes(x = year,
y = pct_events_w_webcast,
color = official)) +
geom_point() +
labs(
title = "Event Webcast Coverage",
subtitle = "Official events all have webcasts, and offseasons are growing in coverage",
x = "Year",
y = "Event Webcast Coverage",
color = "Official Event?"
)
```
## Match Video Coverage
```{r match_video_coverage}
# select(-starts_with("score_breakdown")) %>%
matches %>%
ggplot(aes(x = year,
fill = has_video)) +
geom_bar() +
facet_grid(. ~ official, labeller = label_both) +
labs(
title = "Match Video Coverage",
subtitle = "Video coverage is growing over time, but many offseasons events don't have match data at all.",
x = "Year",
y = "Matches",
fill = "Has Videos"
)
matches %>%
group_by(year, official) %>%
summarize(
n_matches = n(),
n_matches_w_video = sum(has_video),
pct_matches_w_video = mean(has_video)
) %>%
ggplot(aes(x = year,
y = pct_matches_w_video,
color = official)) +
geom_point() +
labs(
title = "Match Video Coverage",
subtitle = "Match video coverage is growing over time for official events, but shrinking for unofficial events",
x = "Year",
y = "Match Video Coverage",
color = "At Official Event?"
)
```