Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnjosephhorton/051c5ddf5ea7a09afa3565c47f78b323 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/051c5ddf5ea7a09afa3565c47f78b323 to your computer and use it in GitHub Desktop.
UC salaries by rank & dept
library(XML)
library(ggplot2)
df <- readHTMLTable("http://projects.dailycal.org/paychecker/departments/")[[1]]
DeMoney <- function(x) as.numeric(gsub(",", "", gsub("\\$", "", as.character(x))))
money.columns <- c("All", "Professor", "Associate professor", "Assistant professor",
"Lecturer")
for (money.column in money.columns){
df[, money.column] <- sapply(df[,money.column], DeMoney)
}
df.long <- df %>%
dplyr::select(-Lecturer, -All) %>%
melt(id.vars = c("Department")) %>%
group_by(Department) %>%
mutate(overall = mean(value[variable == "Professor"], na.rm = TRUE))
df.long$Department <- with(df.long, reorder(Department, overall, mean))
ggplot(data = df.long %>% na.omit, aes(x = value, y = Department, shape = variable)) +
geom_point() +
scale_x_continuous(labels = scales::dollar) +
xlab("Annual salary")
@benmarwick
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment