-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path02_baseball.Rmd
49 lines (33 loc) · 1.74 KB
/
02_baseball.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
name: baseball
# Baseball, WAR, and Ethnicity
This data visualization uses the WAR measure in baseball, a calculation based on the contributions of players. The visualizations show that new ethnicities and races started to be included in Major League baseball, the minority players that joined tended to contribute more than the expected value for players overall. For example, from 1947, when Jackie Robinson joined Major League baseball, and onward, the percent of African American players was outpaced by the percent calculated contributions (WAR) of African American players.
```{r, echo = F}
df <- readxl::read_xlsx("raw_data/MLB Ethnicity 1947-2016.xlsx")
df_gather <- gather(df, "type", "Percent", -Year, -Ethnicity) %>%
mutate(Percent = Percent * 100)
```
A random sample from the data set:
```{r, echo = F}
knitr::kable(sample_n(df_gather, 8), format = "html")
```
---
```{r baseball, eval=F, echo=F, fig.width=8, fig.margin = T}
ggplot(df_gather) +
aes(x = Year, y = Percent) +
facet_wrap(~ Ethnicity) +
geom_area(alpha = .5,
position = "dodge") +
aes(fill = type) +
labs(fill = "") +
labs(x = "") +
labs(title = "American Baseball Demographics 1947-2016") +
labs(subtitle = "Percentage of players and WAR percentage (WAR is a calculation of value contributed)\nData: SABR.org | Vis: @EvaMaeRey for #MakeoverMonday") +
theme_light()
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "baseball"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r paste(knitr::knit(text = partial_knit_chunks("baseball")), collapse = "\n")`
---