-
Notifications
You must be signed in to change notification settings - Fork 32
/
02_white_house_salaries.Rmd
57 lines (45 loc) · 2.09 KB
/
02_white_house_salaries.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
name: salaries
# Salarys of Trump and Obama White House Employees
The data set, originally reported on in an NPR article, shows the difference in the distribution of salaries for the Obama and early Trump White House.
First I plot a histogram of each administration. Then I also contrast boxplots for each administration; the data points are overlayed, jittered to the widths of the boxplots. Plotly is used to make the graph interactive; mousing over will allow you to see who the point represents, their job description and exactly how much they are paid.
```{r, echo = F}
library(readxl)
library(tidyverse)
Trump_White_House_salaries <- read_excel("raw_data/White House salaries.xlsx")
Obama_White_House_salaries <- read_excel("raw_data/White House salaries.xlsx",
sheet = "Obama admin"
)
both_data <- bind_rows(Trump_White_House_salaries, Obama_White_House_salaries) %>%
mutate(position_and_name = paste(NAME, `POSITION TITLE`, sep = "\n"))
```
A random sample from the data set:
```{r, echo = F}
knitr::kable(sample_n(both_data %>% select(-position_and_name), 5), format = "html")
```
---
```{r white_house, eval=F, echo=F}
ggplot(both_data) +
aes(x = ADMINISTRATION) +
aes(y = SALARY) +
geom_jitter(alpha = .5,
height = 0,
width = .25) +
aes(col = ADMINISTRATION) +
geom_boxplot(alpha = .25) +
aes(fill = ADMINISTRATION) +
scale_colour_manual(values =
c("blue", "red")) +
scale_fill_manual(values =
c("blue", "red")) +
theme_bw() +
labs(title = "Obama and Trump White House Salaries as of early 2017") +
labs(subtitle = "Data source: NPR via #MakeoverMonday") +
labs(caption = "Visualization: Gina Reynolds")
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "white_house"
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("white_house")), collapse = "\n")`
---