Created
March 23, 2016 02:22
-
-
Save misternu/239de395ec4659e1e9bb to your computer and use it in GitHub Desktop.
Chi Hack Night March 22
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
| # This script examines school report card data 2014-2015 | |
| # Data downloaded from https://github.com/dailyherald/SchoolReportCards | |
| setwd(dir = "~/Desktop/") | |
| me <- read.csv(file = "me2015.csv") | |
| dem <- read.csv(file="rc2015dem.csv") | |
| # head(me) #query headers | |
| # summary(me) #query summary | |
| # str(dem) #query structure | |
| colnames(me) | |
| together <- merge(x=me, | |
| y=dem, | |
| by="schid") | |
| # View(together) | |
| summary(together$me2015school) | |
| hist(together$me2015school) | |
| mecats <- cut(x=together$me2015school,5) | |
| table(mecats) # /!\ Investigate negative number ## Investigate regex. for ... | |
| together$mecats <- cut(x = together$me2015school, 5) | |
| colnames(together) | |
| if (!require(ggplot2)) { | |
| install.packages("ggplot2") # only needed once | |
| } | |
| library(ggplot2) | |
| ggplot(data=together, aes(x=me2015school))+geom_bar() | |
| ggplot(data=together,aes(x=mecats))+geom_bar() | |
| #Filter NA cat | |
| valid <- subset(together, subset = !is.na(me2015school)) | |
| ggplot(data = valid, aes(x= cut(me2015school, seq(0, 100, by = 20)))) + geom_bar() | |
| #Filter all except NA | |
| notvalid <- subset(valid, subset = is.na(mecats)) | |
| install.packages("reshape2") | |
| library(reshape2) | |
| plotdata <- subset(valid, select = c(schid,me2015school,me2015schAPP)) | |
| head(plotdata) | |
| plotdata_long <- melt (data = plotdata, | |
| id.vars = "schid", | |
| variable.name = "ach_type", | |
| value.name = "pct") | |
| head(plotdata_long) | |
| table(plotdata_long$ach_type) | |
| ggplot(data=plotdata_long,aes(x=pct,fill=ach_type))+geom_bar(binwidth = 10) | |
| ggsave("ach_type.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment