knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v tibble 3.0.4 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.0
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(knitr)
#reading in merged Advanced Placement File -- with only the columns needed
fileAP <- "Advanced Placement.csv"
ap.sch <- read.csv(fileAP)
### How to set your working directory
## In quotation marks, ("C: /Users/BlaiseSevier/Desktop/R Work")
setwd("C:/Users/BlaiseSevier/Desktop/R Work")
els.k12 <- 5296851
nonel.k12 <- 45625438
For more information about the school form see: https://www2.ed.gov/about/offices/list/ocr/docs/2017-18-crdc-school-form.pdf.
TOT_APENR_M Students Enrolled in at least one AP Course: Calculated Male Total TOT_APENR_F Students Enrolled in at least one AP Course: Calculated Female Total SCH_APENR_LEP_M Students Enrolled in at least one AP Course: LEP Male SCH_APENR_LEP_F Students Enrolled in at least one AP Course: LEP Female
TOT_APMATHENR_M Student Enrollment in AP Mathematics: Calculated Male Total TOT_APMATHENR_F Student Enrollment in AP Mathematics: Calculated Female Total SCH_APMATHENR_LEP_M Student Enrollment in AP Mathematics: LEP Male SCH_APMATHENR_LEP_F Student Enrollment in AP Mathematics: LEP Female
TOT_APSCIENR_M Student Enrollment in AP Science: Calculated Male Total TOT_APSCIENR_F Student Enrollment in AP Science: Calculated Female Total SCH_APSCIENR_LEP_M Student Enrollment in AP Science: LEP Male SCH_APSCIENR_LEP_F Student Enrollment in AP Science: LEP Female
TOT_APOTHENR_M Students Enrollment in Other AP Subjects: Calculated Male Total TOT_APOTHENR_F Students Enrollment in Other AP Subjects: Calculated Female Total SCH_APOTHENR_LEP_M Students Enrollment in Other AP Subjects: LEP Male SCH_APOTHENR_LEP_F Students Enrollment in Other AP Subjects: LEP Female
#Code to change the -9s to 0s
ap.sch[ap.sch==-9]<-0
## important columns 27:30
TOT_APENR_M Students Enrolled in at least one AP Course: Calculated Male Total TOT_APENR_F Students Enrolled in at least one AP Course: Calculated Female Total SCH_APENR_LEP_M Students Enrolled in at least one AP Course: LEP Male SCH_APENR_LEP_F Students Enrolled in at least one AP Course: LEP Female
#Computes the total number of a non-English Learner male students in ap courses
#dat$NonELM<- (dat$TOT_ENR_M - dat$TOT_LEPENR_M)
ap.sch$NonELM <- (ap.sch$TOT_APENR_M - ap.sch$SCH_APENR_LEP_M)
sum(ap.sch$NonELM)
## [1] 1292997
#There are 1,292,997 Non-English Learner Male Students Enrolled in AP Courses
#Total female non-EL
#dat$NonELF <-dat$TOT_ENR_F-dat$TOT_LEPENR_F
ap.sch$NonELF <- (ap.sch$TOT_APENR_F - ap.sch$SCH_APENR_LEP_F)
sum(ap.sch$NonELF)
## [1] 1672743
#There are 1,672,743 Non-English Learner Females Enrolled in AP courses.
#total non EL
#dat$NonEL<-dat$NonELF + dat$NonELM
ap.sch$NonEL <- ap.sch$NonELF + ap.sch$NonELM
non.el.ap <- sum(ap.sch$NonEL)
#There are 2,965,740 Non-English Learners Enrolled in AP Courses
#Total Lep Male in Advanced Placement
#dat$ELMGT <- dat$SCH_GTENR_LEP_M
ap.sch$ELM.ap <- ap.sch$SCH_APENR_LEP_M
sum(ap.sch$ELM.ap)
## [1] 29677
## There is 29,677 English Learner Males in AP Courses
#Total LEP Female in GT
#dat$ELFGT <- dat$SCH_GTENR_LEP_F
ap.sch$ELF.ap <- ap.sch$SCH_APENR_LEP_F
sum(ap.sch$ELF.ap)
## [1] 35488
## There are 35,488 EL Females in AP Classes
#dat$ELEnrol <- dat$TOT_LEPENR_M + dat$TOT_LEPENR_F
ap.sch$ELEnrolap <- ap.sch$ELM.ap + ap.sch$ELF.ap
els.ap <- sum(ap.sch$ELEnrolap)
sum(els.ap)
## [1] 65165
## There is 65,165 English learners in AP Courses
round(els.ap/els.k12*100,2)
## [1] 1.23
round(non.el.ap/nonel.k12*100,2)
## [1] 6.5
TOT_APMATHENR_M Student Enrollment in AP Mathematics: Calculated Male Total TOT_APMATHENR_F Student Enrollment in AP Mathematics: Calculated Female Total SCH_APMATHENR_LEP_M Student Enrollment in AP Mathematics: LEP Male SCH_APMATHENR_LEP_F Student Enrollment in AP Mathematics: LEP Female
#Number of ELs in Math AP Classes
sum(ap.sch$SCH_APMATHENR_LEP_F)+ sum(ap.sch$SCH_APMATHENR_LEP_M)
## [1] 6818
# 6,818 ELs in Math
(sum(ap.sch$SCH_APMATHENR_LEP_F)+ sum(ap.sch$SCH_APMATHENR_LEP_M))/ els.ap * 100
## [1] 10.46267
#10.46% of ELs in ap math
##Percentage of ELs in AP Math
TOT_APSCIENR_M Student Enrollment in AP Science: Calculated Male Total TOT_APSCIENR_F Student Enrollment in AP Science: Calculated Female Total SCH_APSCIENR_LEP_M Student Enrollment in AP Science: LEP Male SCH_APSCIENR_LEP_F Student Enrollment in AP Science: LEP Female
#Number of ELs in Science AP Classes
sum(ap.sch$SCH_APSCIENR_LEP_F)+ sum(ap.sch$SCH_APSCIENR_LEP_M)
## [1] 9865
##9,865 English Learners are enrolled in Science
(sum(ap.sch$SCH_APSCIENR_LEP_F)+ sum(ap.sch$SCH_APSCIENR_LEP_M))/ els.ap * 100
## [1] 15.13849
## 15.13% of ELs are in AP Science Classes
TOT_APOTHENR_M Students Enrollment in Other AP Subjects: Calculated Male Total TOT_APOTHENR_F Students Enrollment in Other AP Subjects: Calculated Female Total SCH_APOTHENR_LEP_M Students Enrollment in Other AP Subjects: LEP Male SCH_APOTHENR_LEP_F Students Enrollment in Other AP Subjects: LEP Female
(sum(ap.sch$SCH_APOTHENR_LEP_F) + sum(ap.sch$SCH_APOTHENR_LEP_M)) / els.ap * 100
## [1] 83.66608
sum(ap.sch$SCH_APOTHENR_LEP_F) +
sum(ap.sch$SCH_APOTHENR_LEP_M)+
sum(ap.sch$SCH_APSCIENR_LEP_F)+
sum(ap.sch$SCH_APSCIENR_LEP_M)+
sum(ap.sch$SCH_APMATHENR_LEP_F)+
sum(ap.sch$SCH_APMATHENR_LEP_M)
## [1] 71204
## Els Male and Female in Other
((sum(ap.sch$SCH_APOTHENR_LEP_F) + sum(ap.sch$SCH_APOTHENR_LEP_M))/ els.ap) +
##ELs Male and Female in SCience
((sum(ap.sch$SCH_APSCIENR_LEP_F)+ sum(ap.sch$SCH_APSCIENR_LEP_M))/els.ap)+
## Els Male and Female in Science
((sum(ap.sch$SCH_APMATHENR_LEP_F)+ sum(ap.sch$SCH_APMATHENR_LEP_M))/els.ap)
## [1] 1.092672
#Total Number of ELs who too One or More Exam
one.or.more.el <- sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_F)+ sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_M)
sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_F)/one.or.more.el
## [1] 0.5647205
sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_M)/one.or.more.el
## [1] 0.4352795
(one.or.more.el/els.ap*100)
## [1] 60.68749
## 60.7% took one or more ap exam
## Number of Non-ELs taking the Exam
non.els.APEXAM.oneormore <-(sum(ap.sch$TOT_APEXAM_ONEORMORE_F) - sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_F)) + (sum(ap.sch$TOT_APEXAM_ONEORMORE_M) - sum(ap.sch$SCH_APEXAM_ONEORMORE_LEP_M))
non.els.APEXAM.oneormore
## [1] 2220847
#There are 2,965,740 Non-English Learners Enrolled in AP Courses
non.els.APEXAM.oneormore/non.el.ap*100
## [1] 74.8834
NONExam <- sum(ap.sch$SCH_APEXAM_NONE_LEP_F) + sum(ap.sch$SCH_APEXAM_NONE_LEP_M)
(NONExam/els.ap*100)
## [1] 33.29702
####
(one.or.more.el/els.ap*100) + (NONExam/els.ap*100)
## [1] 93.9845