Source file ⇒ Assignment_5.Rmd
Here is the variables that we will use:
| CONTROL | CCSIZSET | ADM_RATE | NPT41_PUB | NPT43_PUB | NPT45_PUB | NPT41_PRIV | NPT43_PRIV | NPT45_PRIV |
|---|---|---|---|---|---|---|---|---|
| 1 | 14 | 0.8989 | 12683 | 16104 | 15416 | NA | NA | NA |
| 1 | 15 | 0.8673 | 12361 | 16670 | 17291 | NA | NA | NA |
| 2 | 6 | NA | NA | NA | NA | 6736 | NA | NA |
| 1 | 12 | 0.8062 | 14652 | 19016 | 20306 | NA | NA | NA |
| 1 | 13 | 0.5125 | 12342 | 11362 | 2948 | NA | NA | NA |
| 1 | 16 | 0.5655 | 17206 | 21363 | 23748 | NA | NA | NA |
We must then gather the data to put it in glyph-ready form.
| CONTROL | CCSIZSET | ADM_RATE | Quintile | Pub_Pri | AvgCost |
|---|---|---|---|---|---|
| 1 | 14 | 0.8989 | NPT41 | PUB | 12683 |
| 1 | 15 | 0.8673 | NPT41 | PUB | 12361 |
| 1 | 12 | 0.8062 | NPT41 | PUB | 14652 |
| 1 | 13 | 0.5125 | NPT41 | PUB | 12342 |
| 1 | 16 | 0.5655 | NPT41 | PUB | 17206 |
| 1 | 2 | NA | NPT41 | PUB | 6330 |
Finally, we need to plot our data:
econplot <- gdata %>%
ggplot(aes(x = ADM_RATE*100, y = AvgCost/1000)) +
geom_point(color="blue",alpha = 0.5, size = 2) +
geom_smooth(color = "red") +
facet_grid(Pub_Pri ~ Quintile) +
theme_bw() +
ggtitle("Scorecard") +
xlab("Admissions Rate, %") +
ylab("Next Cost per Year, $'000") +
theme(plot.title = element_text(size = 25),
axis.text.y = element_text(size = 10),
axis.title.x = element_text(size = 10),
axis.title = element_text(size = 10))
econplot
## Warning: Removed 12311 rows containing non-finite values (stat_smooth).
## Warning: Removed 12311 rows containing missing values (geom_point).