Created
October 5, 2015 17:47
-
-
Save laurakwiley/25c317015a0b2e3fe40e to your computer and use it in GitHub Desktop.
A dplyr version of the ARL Library Investment Index example in the Intro to R and Shiny Tutorial (https://github.com/HeardLibrary/workshops/blob/gh-pages/_posts/2015-10-02-intro-to-r-and-shiny.md)
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(ggplot2) | |
library(scales) | |
library(dplyr) | |
library(stringr) | |
arl <- read.csv(file = "index13.csv",header = TRUE,skip = 1) %>% | |
tbl_df() %>% ## turn into tbl_df | |
select(Institution = Institution.Name.1, | |
Total = Total.Library.Expenditures, | |
Salaries = Salaries...Wages.Professional.Staff, | |
Material = Total.Library.Materials.Expenditures, | |
Staff = Professional.plus.support.staff) %>% ## Select and Rename the five columns of interest | |
slice(-116) %>% ## Remove the wonky row of data | |
mutate(Wages = as.numeric(str_replace_all(Salaries, ",",""))) ## Create Wages variable that is a numeric version of Salaries | |
Vandy <- arl %>% filter(Institution == "VANDERBILT") | |
ggplot(arl, aes(x=Staff, y=Wages)) + geom_point() + stat_smooth(method="lm") + scale_y_continuous(labels = comma) + ggtitle("ARL Expenditures") + xlab("All Staff") + ylab("Professional Salaries") + geom_point(data=Vandy, colour="red") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment