Install libraries
Import and filter 2018/2019 Data
zData1819 <- rio::import("https://github.com/mrm081/busdrivers/blob/master/AR_School_Homeless_Data1819.xlsx?raw=true", which = "Data")
## New names:
## * `` -> ...1
zData1819 <- janitor::clean_names(zData1819)
zData1819[3:16] <- lapply(zData1819[3:16], as.numeric)
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1819[3:16], as.numeric): NAs introduced by coercion
Schools1819 <- zData1819 %>%
select(district_name, district_percent_homeless) %>%
filter(district_name == "Arkansas Overall" | district_name == "NEWPORT SCHOOL DISTRICT")
colnames(Schools1819)[2] <- c("homeless_pct_1819")
head(Schools1819)
## district_name homeless_pct_1819
## 1 Arkansas Overall 0.02447637
## 2 NEWPORT SCHOOL DISTRICT 0.11367673
Import and Filter 2014/2015 Data
zData1415 <- rio::import("https://github.com/mrm081/busdrivers/blob/master/AR_School_Homeless_data1415.xlsx?raw=true", which = "Data")
## New names:
## * `` -> ...1
zData1415 <- janitor::clean_names(zData1415)
zData1415[3:16] <- lapply(zData1415[3:16], as.numeric)
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
## Warning in lapply(zData1415[3:16], as.numeric): NAs introduced by coercion
Schools1415 <- zData1415 %>%
select(district_name, district_percent_homeless) %>%
filter(district_name == "Arkansas Overall" | district_name == "NEWPORT SCHOOL DISTRICT")
colnames(Schools1415)[2] <- c("homeless_pct_1415")
head(Schools1415)
## district_name homeless_pct_1415
## 1 Arkansas Overall 0.01775363
## 2 NEWPORT SCHOOL DISTRICT 0.09636651
Join Data together
CompareData<- Schools1415 %>%
inner_join(Schools1819, by=("district_name"))
head(CompareData)
## district_name homeless_pct_1415 homeless_pct_1819
## 1 Arkansas Overall 0.01775363 0.02447637
## 2 NEWPORT SCHOOL DISTRICT 0.09636651 0.11367673
Find percentage change between 2014/2015 school year to 2018/2019 school year.
CompareData <- CompareData %>%
mutate(PctChg = (homeless_pct_1819 - homeless_pct_1415)/homeless_pct_1819)
CompareData$PctChg <- percent(CompareData$PctChg)
CompareData$homeless_pct_1415 <- percent(CompareData$homeless_pct_1415)
CompareData$homeless_pct_1819 <- percent(CompareData$homeless_pct_1819)
head(CompareData)
## district_name homeless_pct_1415 homeless_pct_1819 PctChg
## 1 Arkansas Overall 1.78% 2.45% 27.47%
## 2 NEWPORT SCHOOL DISTRICT 9.64% 11.37% 15.23%
Graphing the Percentage change
CompareData %>%
ggplot(aes(x = district_name, y = PctChg, fill = PctChg)) +
geom_col(position = "dodge", show.legend = FALSE) +
theme(axis.text.x = element_text(angle = 90)) +
geom_text(aes(label = PctChg), hjust = -.5, vjust = -.5, size = 3.5) +
scale_y_continuous(limits=c(0, .35),labels = scales::percent) +
coord_flip() +
labs(title = "Percent Change in Homeless Students",
subtitle = "14/15 School Year - 18/19 School Year",
caption = "Source: Dept. of Education, Graphic by Matthew Moore - 4/21/20",
y="Percentage Change",
x="School")
This chart is not very representative of the data, so let’s try another couple of graphs.
CompareData %>%
ggplot(aes(x = district_name, y = homeless_pct_1415, fill = homeless_pct_1415)) +
geom_col(position = "dodge", show.legend = FALSE) +
theme(axis.text.x = element_text(angle = 90)) +
geom_text(aes(label = homeless_pct_1415), hjust = -.5, vjust = -.5, size = 3.5) +
scale_y_continuous(limits=c(0, .11),labels = scales::percent) +
coord_flip() +
labs(title = "Homeless Students Percentage",
subtitle = "2014/2015 School Year",
caption = "Source: Dept. of Education, Graphic by Matthew Moore - 4/21/20",
y="Percentage of Homeless Students",
x="")
Homeless1819 <- CompareData %>%
ggplot(aes(x = district_name, y = homeless_pct_1819, fill = homeless_pct_1819)) +
geom_col(position = "dodge", show.legend = FALSE) +
theme(axis.text.x = element_text(angle = 90)) +
geom_text(aes(label = homeless_pct_1819), hjust = -.5, vjust = -.5, size = 3.5) +
scale_y_continuous(limits=c(0, .13),labels = scales::percent) +
coord_flip() +
labs(title = "Homeless Students Percentage",
subtitle = "2018/2019 School Year",
caption = "Source: Dept. of Education, Graphic by Matthew Moore - 4/21/20",
y="Percentage of Homeless Students",
x="")
Homeless1819
ggsave("Homeless1819.png", device = "png",width=9,height=6, dpi=800)
MoreSchools1819 <- zData1819 %>%
select(district_name, district_percent_homeless) %>%
filter(district_name == "Arkansas Overall" | district_name == "NEWPORT SCHOOL DISTRICT" |
district_name =="SPRINGDALE SCHOOL DISTRICT" | district_name == "FAYETTEVILLE SCHOOL DISTRICT" |
district_name == "BENTONVILLE SCHOOL DISTRICT" | district_name == "FARMINGTON SCHOOL DISTRICT") %>%
arrange(desc(district_percent_homeless))
MoreSchools1819$district_percent_homeless <- percent(MoreSchools1819$district_percent_homeless)
head(MoreSchools1819)
## district_name district_percent_homeless
## 1 NEWPORT SCHOOL DISTRICT 11.37%
## 2 Arkansas Overall 2.45%
## 3 FAYETTEVILLE SCHOOL DISTRICT 2.37%
## 4 BENTONVILLE SCHOOL DISTRICT 1.49%
## 5 SPRINGDALE SCHOOL DISTRICT 1.03%
## 6 FARMINGTON SCHOOL DISTRICT 0.48%
Chart Time
MoreSchoolsGraphics <- MoreSchools1819 %>%
ggplot(aes(x = reorder(district_name, district_percent_homeless), y = district_percent_homeless, fill = district_percent_homeless)) +
geom_col(position = "dodge", show.legend = FALSE) +
geom_text(aes(label = district_percent_homeless), hjust = -.5, vjust = -.5, size = 3.5) +
scale_y_continuous(limits=c(0, .14),labels = scales::percent) +
coord_flip() +
labs(title = "Homeless Students Percentage",
subtitle = "2018/2019 School Year",
caption = "Source: Dept. of Education, Graphic by Matthew Moore - 4/27/20",
y="Percentage of Homeless Students",
x="")
MoreSchoolsGraphics
ggsave("MoreSchoolGraphics.png", device = "png",width=9,height=6, dpi=800)