Created
June 4, 2018 21:01
-
-
Save mcfrank/fa12c417f3d2ccc12a2b0131093b3c4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(lubridate) | |
| d <- read_csv("psychjobwiki.csv") | |
| ms <- d %>% | |
| group_by(year, category) %>% | |
| count() %>% | |
| left_join(d %>% group_by(year) %>% count() %>% rename(total = n)) %>% | |
| mutate(prop = n / total) | |
| ggplot(ms, aes(x = year, y = prop, col = category)) + | |
| geom_point(aes(size = n), alpha = .3) + | |
| geom_smooth(se = FALSE, method = "lm") + | |
| ggthemes::theme_few() + | |
| theme(legend.position = "bottom") + | |
| xlab("Year") + | |
| ylab("Proportion of Total Jobs") + | |
| scale_size_area(guide = FALSE) + | |
| ggthemes::scale_color_ptol(name = "") | |
| d$deadline <- as_date(d$deadline) | |
| d$months <- month(d$deadline) | |
| ggplot(d, aes(x = months, fill = year)) + | |
| geom_histogram(binwidth = 1, aes(y = ..density..)) + | |
| ggthemes::theme_few() + | |
| facet_wrap(~ year)+ | |
| theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5)) + | |
| geom_vline(data = d %>% group_by(year) %>% summarise(months = mean(months)), | |
| aes(xintercept = months), | |
| col = "red", lty = 2) + | |
| scale_x_continuous(breaks = c(0,3,6,9,12), name = "Deadline Month") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment