Last active
August 29, 2015 14:07
-
-
Save dggoldst/0c7c1665f87456b9c514 to your computer and use it in GitHub Desktop.
This file contains 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(dplyr) | |
df=read.csv("directory.csv.gz") | |
df$dept2=tolower(df$dept) | |
df$dept2[grep("psych",df$dept2)]="Psychology" | |
df$dept2[grep("marketing",df$dept2)]="Marketing" | |
df$dept2[grep("economics",df$dept2)]="Economics" | |
df$dept2[df$dept2=="management"]="Management" | |
df$dept2[df$dept2=="management department"]="Management" | |
df$dept2[df$dept2=="department of management"]="Management" | |
df$dept2[df$dept2=="dept of management"]="Management" | |
df$dept2[grep("management and organizations",df$dept2)]="Management" | |
df$dept2[df$dept2=="management & organizations dept"]="Management" | |
df$dept2[grep("organizational",df$dept2)]="Management" | |
df$dept2[grep("school of business",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("college of business",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("school of management",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("business school",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("wharton",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("fuqua",df$dept2)]="Unspecified B-School" | |
df$dept2[grep("decision",df$dept2)]="Decision Making" | |
df$dept2[grep("accounting",df$dept2)]="Accounting" | |
df$dept2[grep("health",df$dept2)]="Health" | |
df$dept2[grep("medicine",df$dept2)]="Health" | |
plot_data = df %>% | |
group_by(dept2) %>% | |
summarize(count=length(dept2)) %>% | |
arrange(-count) %>% | |
filter(count>=5 & dept2!=" ") | |
names(plot_data)=c("Department","Count") | |
plot_data$Department=factor(plot_data$Department,levels=plot_data$Department) | |
p=ggplot(plot_data,aes(x=Department,y=Count,fill=Department)) | |
p=p+geom_bar(stat="identity") | |
p=p+labs(x="",y="",title="Members in Areas with 5+ Members") | |
p=p+theme(legend.position = "none") | |
p=p+theme( axis.text.x = element_text(angle=90, vjust=0.5),legend.position="none") | |
ggsave(plot=p,file="MembersByArea.png",width=4,height=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment