OSPI K - 12 homelessness data for WA Schools. Political piece here.
library(sqldf)
library(plyr)
library(lattice)
## Mux in Census SAIPE Poverty Data for Whatcom County School Districts with OSPI Children in Homelessness Data
## Follows from ChildrenPovertyWhatcomCounty.r
## setwd("C:/Politics")
header <- c("FIPS","CCDID","DName","TotPop","SAChild","SAChildPovHH")
t5 <- data.frame(read.delim("t4.txt",sep="",col.names=header,fill=TRUE))
# substitute School Districts of your choice here
t6 <- droplevels(sqldf("Select * from t5 where
DNAME LIKE 'Blaine' OR
DNAME LIKE 'Ferndale' OR
DNAME LIKE 'Bellingham' OR
DNAME LIKE 'Lynden' OR
DNAME LIKE 'NooksackValley' OR
DNAME LIKE 'Meridian' OR
DNAME LIKE 'MountBaker' OR
DNAME LIKE 'Concrete' OR
DNAME LIKE 'Sedro-Woolley' "))
## Original data for the CSV below is found here: http://www.k12.wa.us/HomelessEd/pubdocs/2013-14DistrictDemographics.xlsx
## The data needs to reformatted for a R and CSV. I did:
# Remove 'School District' form District Name column
# Remove spaces from all headers
# Remove last line of totals
# Replace n<10 with 'NA'
# Remove rows that reference Service Districts
# The White Paper on the latest data can be found here: http://www.k12.wa.us/LegisGov/2015documents/HomelessStudentsJan2015.pdf
OSPI <- read.csv("2014OSPIStudentHomelessness.csv",strip.white = TRUE,header=TRUE)
# All WA State data: Top 25 volume and percentage
b.1 <-arrange(data.frame(xtabs((CountIdentifiedHomeless)~ DistrictName, data=OSPI)),desc(Freq));colnames(b.1) <- c("Children In Homelessness in District", "Count")
b.2 <- arrange(data.frame(xtabs(as.integer((CountIdentifiedHomeless/DistrictEnrollment) * 100) ~ DistrictName, data=OSPI)),desc(Freq));colnames(b.2) <- c("Children In Homelessness / District Enrollment", "PCT")
b.3 <- cbind(b.1,b.2)[1:25,]
b.4 <- b.3[,c(1,3)]
b.4[,2] %in% b.4[,1]
b.3
write.csv(b.3,"ChildrenInHomelessness2013-2104.csv")
h1 <- droplevels(sqldf("Select DistrictName,DistrictEnrollment,CountIdentifiedHomeless from OSPI where
DistrictName LIKE 'Blaine' OR
DistrictName LIKE 'Ferndale' OR
DistrictName LIKE 'Bellingham' OR
DistrictName LIKE 'Lynden' OR
DistrictName LIKE 'Nooksack Valley' OR
DistrictName LIKE 'Meridian' OR
DistrictName LIKE 'Mount Baker' OR
DistrictName LIKE 'Concrete' OR
DistrictName LIKE 'Sedro-Woolley' "))
## Can just cbind data because both are in alpha order
## Would need similar District Names to Merge?
h2 <- cbind(t6,h1)
h2[,c(3,4,8,5,6,9)]
cat('
DName TotPop DistrictEnrollment SAChild SAChildPovHH CountIdentifiedHomeless
1 Bellingham 104767 11136 12340 1908 471
2 Blaine 16388 2120 2380 420 49
3 Concrete 4921 542 717 168 26
4 Ferndale 31180 5174 5885 912 126
5 Lynden 18863 2842 3612 397 58
6 Meridian 10032 1790 1630 249 41
7 MountBaker 14724 1880 2573 515 52
8 NooksackValley 10317 1574 1996 304 49
9 Sedro-Woolley 26646 4305 4491 745 173
')
h2a <- h2[,c(3,4,8,5,6,9)]
colSums(h2a[,2:6])
# TotPop DistrictEnrollment SAChild SAChildPovHH CountIdentifiedHomeless
# 227806 29573 33994 5369 1004
# All Whatcom County data
h3 <- arrange(data.frame(xtabs((CountIdentifiedHomeless)~ DistrictName, data=h2)),desc(Freq))
h4 <- arrange(data.frame(xtabs((CountIdentifiedHomeless/DistrictEnrollment) ~ DistrictName, data=h2)),desc(Freq))
h5 <- arrange(data.frame(xtabs((TotPop)~ DistrictName, data=h2)),desc(Freq))
h6 <- arrange(data.frame(xtabs((CountIdentifiedHomeless/TotPop) ~ DistrictName, data=h2)),desc(Freq))
# require(lattice)
with(h2,barchart(DName ~ SAChildPovHH + CountIdentifiedHomeless ,auto.key=TRUE,
main="(SAIPE 2013) Children in Poverty and (OSPI 2013 - 2014) Homeless Counts K - 12 for Nine Whatcom School Districts",xlab=NULL,xlim=c(0,2000),cex.main=1.75,box.ratio=6))
with(h3,barplot(Freq,names.arg=DistrictName,cex.names= .85,col="yellow"))
mtext("OSPI 2013-2014 School Children in Homelessness in 9 (whole or in part) Whatcom County School Districts:", line=-5,cex=1.75)
mtext("1,004 out of 29,573 Enrolled School Children (3.3%) are living in homelessness.", line=-7,cex=1.75)
mtext("OSPI defines homelessness more broadly than 'Point in Time' estimates.",line=-9,cex=1.75)
mtext("Categories include: Unsheltered,Sheltered,'Doubled up','Motel/Hotel'",line=-11,cex=1.75)
with(h4,barplot(Freq * 100,names.arg=DistrictName,cex.names= .85,las=1,ylab="Percent",col="red"))
mtext("School Children in Homelessness / Total Children Enrolled in District",cex=1.75)
with(h5,barplot(Freq,names.arg=DistrictName,cex.names= .85,cex=.65,las=1,col="light blue"))
mtext("Total SAIPE Population in District",cex=1.75)
with(h6,barplot(Freq * 100,names.arg=DistrictName,cex.names= .85,las=1,ylab="Percent",col="blue"))
mtext("School Children in Homelessness / Total Population in District",cex=1.75)
h7 <- arrange(data.frame(xtabs((SAChildPovHH/DistrictEnrollment) * 100 ~ DistrictName, data=h2)),desc(Freq)); colnames(h7) <- c("ChildInPoverty / DistrictEnrollment", "PCT")
h8 <- arrange(data.frame(xtabs((CountIdentifiedHomeless/DistrictEnrollment) * 100 ~ DistrictName, data=h2)),desc(Freq)); colnames(h8) <- c("K-12 Child in Homelessness / District Enrollment","PCT")
h7a <- arrange(data.frame(xtabs((SAChildPovHH/DistrictEnrollment) * 100 ~ DistrictName, data=h2)),desc(Freq)); colnames(h7a) <- c("ChildInPoverty / DistrictEnrollment", "PCT")
h8a <- arrange(data.frame(xtabs((CountIdentifiedHomeless/DistrictEnrollment) * 100 ~ DistrictName, data=h2)),desc(Freq)); colnames(h8a) <- c("K-12 Child in Homelessness / District Enrollment","PCT")
h9 <- arrange(data.frame(xtabs(CountIdentifiedHomeless ~ SAChildPovHH, data=h2)),desc(Freq)); colnames(h9) <- c("ChildinPoverty","K-12 Child in Homelessness")
h10 <- arrange(data.frame(xtabs(DistrictEnrollment ~ TotPop, data=h2)),desc(Freq)); colnames(h10) <- c("TotPop","DistrictEnrollment")
No comments:
Post a Comment