Skip to content

Instantly share code, notes, and snippets.

@kjhealy
Forked from avyfain/uc_salaries.r
Created June 1, 2018 20:42
Show Gist options
  • Save kjhealy/0d13145517911c21a5e4164e94f1f8ee to your computer and use it in GitHub Desktop.
Save kjhealy/0d13145517911c21a5e4164e94f1f8ee to your computer and use it in GitHub Desktop.
library(XML)
library(ggplot2)
df <- readHTMLTable("http://projects.dailycal.org/paychecker")[[1]]
colnames(df)[4] <- "Salary"
df$Salary <- as.numeric(gsub('[$,]', '', df$Salary))
p <- ggplot(df, aes(x=Department, y=Salary)) + coord_flip()
p + geom_boxplot(aes(color=Rank,
x=reorder(Department, Salary, FUN=max))) +
scale_y_continuous(labels = scales::dollar) +
labs(title="Salaries by Department",
subtitle="University of California System",
y="Annual Salary (2015)",
x="Department",
caption="Source: http://projects.dailycal.org/paychecker/\n by @avyfain, inspired by @johnjhorton") +
theme(plot.caption = element_text(size=7.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment