Skip to content

Instantly share code, notes, and snippets.

@saveyak
Created February 25, 2021 16:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saveyak/de6e04c35b2d378fcad747ab5ed13680 to your computer and use it in GitHub Desktop.
Save saveyak/de6e04c35b2d378fcad747ab5ed13680 to your computer and use it in GitHub Desktop.
Arts Education in New Orleans
#I wrote this code to produce the graphics used in the public policy report, "Will the Arts Come Marching In? Access to Arts Education in Post-Katrina New Orleans," by Sarah Woodward of Tulane University. Read the report here: https://educationresearchalliancenola.org/files/publications/20200915-Woodward-Will-the-Arts-Come-Marching-in-Access-to-Arts-Education-in-Post-Katrina-New-Orleans.pdf
library(readxl)
library(tidyverse)
library(ggplot2)
library(extrafont)
library(scales)
library(grid)
library(stringr) #lets you use str_wrap()
###Themes and palettes####
era_palette = c("#073b47", "#a8c42e", "#d65C2A", "#3BBAE0", "#7C878E", "#e59918")
blue_gradient = c("#073b47", "#145A6D","#217A93","#2e9ab9","#3bbae0")
#http://www.perbang.dk/rgbgradient/
horizontal_theme = theme_bw(base_family = "Georgia") +
theme(
panel.border = element_rect(color = "black", fill=NA),
axis.title.y = element_text(hjust=0.5, size = 12, margin=margin(l=10, r=10)),
axis.text.y = element_text(size=12, margin=margin(r=10), color="black", hjust=0),
axis.text.x = element_text(size=12, margin=margin(t=10, b=10), color="black"),
axis.title.x = element_blank(),
# axis.title.x = element_text(hjust=0.5, size = 12, margin=margin(t=10, b=10)),
legend.title = element_blank(),
legend.position= "bottom",
legend.margin=margin(-10, 10, 0, 0),
legend.text = element_text(size = 12, margin = margin(r = 10)),
panel.grid.major.x = element_blank() ,
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(size=1),
panel.grid.minor.y = element_blank(),
plot.margin = margin(30, 10, 10, 10, "pt"),
strip.text.x = element_text(size = 12))
#Data####
#Note: The dataset include non-publicly-available information on individual schools, and therefore I will not share it online.
data = "arts_ed_data.xlsx"
nola_k8_2016 = read_excel(data, sheet=1)
nola_hs_2016 = read_excel(data, sheet=2)
comparison_k8 = read_excel(data, sheet=3)
comparison_hs = read_excel(data, sheet=4)
talent = read_excel(data, sheet=7)
nola_k8_filtered = nola_k8_2016 %>% filter(!is.na(sps_lvl)) %>% filter(sps_lvl != "T")
#Figure 1####
#Figure 1: Fewer K-8 students in New Orleans were enrolled in arts and enrichment courses than in Caddo or East Baton Rouge Parishes.
comparison_k8$district = factor(comparison_k8$district, levels=unique(comparison_k8$district))
ggplot(comparison_k8, aes(x=year, y=pct_artenrich, color=district, group=district)) +
geom_line(size=1) +
geom_point(size=3) +
theme_bw(base_family = "Georgia") +
horizontal_theme +
labs(y = "% of K-8 Students\nin Arts or Enrichment Courses") +
scale_y_continuous(expand = c(0, 0),
limits=c(0,100),
breaks = seq(0, 100, by=20),
label = function(x) paste0(x,"%")) +
scale_color_manual(values=era_palette)
ggsave("formatted_figs/art_fig1_formatted.pdf", w=6.5, h=3.5, unit="in", device=cairo_pdf)
#Figure 2####
#Figure 2: For high school students, arts enrollment rates were similar across the three parishes.
comparison_hs_nojeff = comparison_hs %>% filter(district != "Jefferson Parish")
comparison_hs_nojeff$district = factor(comparison_hs_nojeff$district, levels=unique(comparison_hs_nojeff$district))
ggplot(comparison_hs_nojeff, aes(x=year, y=pct_arts_course, color=district, group=district)) +
geom_line(size=1) +
geom_point(size=3) +
horizontal_theme +
labs(y = "% of High School Students\nin Arts Courses",
title = "") +
scale_y_continuous(expand = c(0, 0),
limits=c(0,100),
breaks = seq(0, 100, by=20),
label = function(x) paste0(x,"%")) +
scale_color_manual(values=era_palette)
ggsave("formatted_figs/art_fig2_formatted.pdf", w=6.5, h=3.5, unit="in", device=cairo_pdf)
#Figure 3####
#Figure 3: There is no relationship between school letter grades and enrollment in arts and enrichment.
#This is the average percent enrollment at each school, not a weighted average
k8_sps = nola_k8_filtered %>% group_by(sps_lvl) %>% summarize(mean_enrollment = mean(pct_artenrich))
k8_sps$grade = "K-8"
hs_sps = nola_hs_2016 %>% group_by(sps_lvl) %>% summarize(mean_enrollment = mean(pct_arts_course))
hs_sps$grade = "High School"
both_sps = rbind(k8_sps, hs_sps)
both_sps$grade = factor(both_sps$grade, levels = c("K-8", "High School"))
ggplot(both_sps, aes(x=grade, y=mean_enrollment, fill=sps_lvl))+
geom_bar(stat="identity", width=0.9, position=position_dodge(width=0.9)) +
horizontal_theme +
labs(x = "School Performance Score", y = "Average % Enrollment\nin Arts or EnrichmentCourses", title="") +
scale_y_continuous(expand = c(0, 0),
limits=c(0,100),
breaks = seq(0, 100, by=20),
labels = function(x) paste0(x, "%")) +
scale_fill_manual(values = blue_gradient) +
geom_text(aes(label=paste0(round(mean_enrollment), "%")), size=4.2333, position=position_dodge(width=0.9), family = "Georgia", hjust=0.5, vjust=-0.5) +
labs(fill="School Performance Score:") + #Changes legend title
theme(legend.position = "bottom", legend.title = element_text())
ggsave("formatted_figs/art_fig3_formatted.pdf", w=6.5, h=3.5, unit="in", device=cairo_pdf)
#Figure 4####
#Figure 4: Arts enrollment rates vary widely across schools, but standalone charter schools had higher rates than network charters.
#Note: In this case I am *not* filtering out schools with no letter grades
no_OPSB_k8 = nola_k8_2016 %>% filter(nola_type16 != "OPSB direct-run")
no_OPSB_hs = nola_hs_2016 %>% filter(nola_type16 != "OPSB direct-run")
no_OPSB_hs = no_OPSB_hs %>% rename(pct_artenrich = pct_arts_course)
no_OPSB_both = rbind(no_OPSB_k8, no_OPSB_hs)
#Drop Cohen which is incorrectly listed as K-8
no_OPSB_both = no_OPSB_both %>% filter(grades != "DROP THIS")
no_OPSB_both$grades = factor(no_OPSB_both$grades, levels = unique(no_OPSB_both$grades))
no_OPSB_both$nola_type16 = ifelse(no_OPSB_both$nola_type16 == "Standalone charter", "Standalone", "Network")
ggplot(no_OPSB_both, aes(y=pct_artenrich, x=nola_type16)) +
geom_point(size=2, color="#e59918") +
scale_color_manual(values=era_palette) +
theme_bw(base_family = "Georgia") +
scale_y_continuous(limits=c(0,100),
breaks = seq(0, 100, by=20),
labels = function(x) paste0(x, "%")) +
horizontal_theme +
labs(y = "% of Students in Arts or Enrichment") +
stat_summary(fun.y=mean, geom="point", shape=18,
size=4, color="#073b47") +
stat_summary(aes(label=paste0(round(..y..),"%")), fun.y=mean, geom="text", size=3.52778, hjust=-0.5, family="Georgia") +
facet_grid(cols = vars(grades))
#If you want the word average: stat_summary(aes(label=paste0("Average: ", round(..y..),"%") %>% str_wrap(width=8)), fun.y=mean, geom="text", size=3.52778, hjust=-0.1, family="Georgia")
#Or alternatively: labels = paste0("Average: ", scales::percent(VARNAME, accuracy = 1)) %>% stringr::str_wrap(width = 8)
#ggsave("formatted_figs/art_fig4_test.pdf", w=6.5, h=4.5, unit="in", device=cairo_pdf)
ggsave("formatted_figs/art_fig4_formatted.pdf", w=6.5, h=4.5, unit="in", device=cairo_pdf)
View(no_OPSB_both)
#Figure 5####
#Figure 5: A-rated schools had a far higher percentage of students identified as artistically talented.
View(talent)
talent$pct_talented = talent$pct_talented*100
talent$grade = factor(talent$grade, levels=c("K-8", "High School"))
ggplot(talent, aes(x=grade, y=pct_talented, fill=SPS))+
geom_bar(stat="identity", width=0.9, position=position_dodge(width=0.9)) +
horizontal_theme +
labs(x = "School Performance Score", y = "% of Students Identified as Talented", title="") +
scale_y_continuous(expand = c(0, 0),
limits=c(0,10),
breaks = seq(0, 10, by=2),
labels = function(x) paste0(x, "%")) +
scale_fill_manual(values = blue_gradient) +
geom_text(aes(label=paste0(pct_talented, "%")), size=3.52778, position=position_dodge(width=0.9), family = "Georgia", hjust=0.5, vjust=-0.5) +
labs(fill="School Performance Score:") + #Changes legend title
theme(legend.position = "bottom", legend.title = element_text())
ggsave("formatted_figs/art_fig5_formatted.pdf", w=6.5, h=3.5, unit="in", device=cairo_pdf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment