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 Algebra I  File -- with only the columns needed

fileAlgI <- "Algebra I.csv"

algI.sch <- read.csv(fileAlgI)

### 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


#Total Number of Students in HS
tot_enrol_hs <- 14183488
#Total Number of Non-Els in HS
non.el.hs <- 13108063
#Total Number of LEP in HS 
tot_lep_hs <- 1075425 

CRDC Survey Information

For more information about the school form see: https://www2.ed.gov/about/offices/list/ocr/docs/2017-18-crdc-school-form.pdf.

TOT_ALGENR_G08_M Student Enrollment in Algebra I (Grade 8, UG Middle School Age): Calculated Male Total TOT_ALGENR_G08_F Student Enrollment in Algebra I (Grade 8, UG Middle School Age): Calculated Female Total SCH_ALGENR_G08_LEP_M Student Enrollment in Algebra I (Grade 8, UG Middle School Age): LEP Male SCH_ALGENR_G08_LEP_F Student Enrollment in Algebra I (Grade 8, UG Middle School Age): LEP Female

TOT_ALGENR_GS0910_M Student Enrollment in Algebra I (Grades 9-10): Calculated Male Total TOT_ALGENR_GS0910_F Student Enrollment in Algebra I (Grades 9-10): Calculated Female Total SCH_ALGENR_GS0910_LEP_M Student Enrollment in Algebra I (Grades 9-10): LEP Male SCH_ALGENR_GS0910_LEP_F Student Enrollment in Algebra I (Grades 9-10): LEP Female

TOT_ALGENR_GS1112_M Student Enrollment in Algebra I (Grades 11-12): Calculated Male Total TOT_ALGENR_GS1112_F Student Enrollment in Algebra I (Grades 11-12): Calculated Female Total SCH_ALGENR_GS1112_LEP_M Student Enrollment in Algebra I (Grades 11-12): LEP Male SCH_ALGENR_GS1112_LEP_F Student Enrollment in Algebra I (Grades 11-12): LEP Female

Change Code from 0s to 9s

#Code to change the -9s to 0s

algI.sch[algI.sch==-9]<-0

## important columns 27:30

Grade 8 Algebra I

Non-English Learner Male Students Enrolled in Algebra I Courses Grade 8

#Computes the total number of a non-English Learner male students in Algebra I courses

#dat$NonELM<- (dat$TOT_ENR_M - dat$TOT_LEPENR_M)

algI.sch$NonELM <- (algI.sch$TOT_ALGENR_G08_M - algI.sch$SCH_ALGENR_G08_LEP_M)

sum(algI.sch$NonELM)
## [1] 451949
#There are 451949 Non-English Learner Male Students Enrolled in Algebra I G8 

Non-English Learner Female Students in Algebra I Grade 8

#Total female non-EL 
#dat$NonELF <-dat$TOT_ENR_F-dat$TOT_LEPENR_F

algI.sch$NonELF <- (algI.sch$TOT_ALGENR_G08_F - algI.sch$SCH_ALGENR_G08_LEP_F)

sum(algI.sch$NonELF)
## [1] 480594
#There are 480594 Non-English Learner Females Enrolled in Algebra I Grade 8 courses.

Total Non ELs in Algebra I Grade 8

#total non EL
#dat$NonEL<-dat$NonELF + dat$NonELM

algI.sch$NonEL <- algI.sch$NonELF + algI.sch$NonELM

non.el.AlgebraG08 <- sum(algI.sch$NonEL)
non.el.AlgebraG08
## [1] 932543
#There are 932,543 Non-English Learners Enrolled in Algebra I 

English Learners in Algebra I in Grade 8

English Learner Males in Algebra I

#Total Lep Male in Algebra I 

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

algI.sch$ELM.AIG8 <- algI.sch$SCH_ALGENR_G08_LEP_M

sum(algI.sch$SCH_ALGENR_G08_LEP_M)
## [1] 13375
sum(algI.sch$ELM.AIG8)
## [1] 13375
## There is 13,375 English Learner Males in Algebra I Grade 8 

English Learner Females in Algebra I Grade 8

#Total LEP Female in GT
#dat$ELFGT <- dat$SCH_GTENR_LEP_F

algI.sch$ELF.AIG8 <- algI.sch$SCH_ALGENR_G08_LEP_F

sum(algI.sch$ELF.AIG8)
## [1] 10907
## There are 10,907 EL Females in Algebra I Grade 8 Classes 

Total English Learners in Algebra I

#dat$ELEnrol <- dat$TOT_LEPENR_M + dat$TOT_LEPENR_F

algI.sch$ELEnrolAIG8 <- algI.sch$ELM.AIG8 + algI.sch$ELF.AIG8

els.AIG8 <- sum(algI.sch$ELEnrolAIG8)

sum(els.AIG8)
## [1] 24282
## There is 24,282 English learners in Algebra I Grade 8  

Percentage of ELs and Non ELs in Algebra I Grade 8 Courses

#Percentage of ELs in Algebra 8 Grade 8

round(els.AIG8/tot_lep_hs*100,2)
## [1] 2.26
round(els.AIG8/els.k12*100,2)
## [1] 0.46
round(non.el.AlgebraG08/non.el.hs*100,2)
## [1] 7.11
round(non.el.AlgebraG08/nonel.k12*100,2)
## [1] 2.04

Grade 9-10 Algebra I

Non-English Learner Male Students Enrolled in Algebra I Courses Grade 9-10

#Computes the total number of a non-English Learner male students in Algebra I courses

#dat$NonELM<- (dat$TOT_ENR_M - dat$TOT_LEPENR_M)

algI.sch$NonELM.GS0910 <- (algI.sch$TOT_ALGENR_GS0910_M - algI.sch$SCH_ALGENR_GS0910_LEP_M)

sum(algI.sch$NonELM.GS0910)
## [1] 1388378
#There are 1,388,378 Non-English Learner Male Students Enrolled in Algebra I G9-10

Non-English Learner Female Students in Algebra I Grade 9-10

#Total female non-EL 
#dat$NonELF <-dat$TOT_ENR_F-dat$TOT_LEPENR_F

algI.sch$NonELF.GS0910 <- (algI.sch$TOT_ALGENR_GS0910_F - algI.sch$SCH_ALGENR_GS0910_LEP_F)

sum(algI.sch$NonELF.GS0910)
## [1] 1275470
#There are 1,275,470 Non-English Learner Females Enrolled in Algebra I Grade 9-10 courses.

Total Non ELs in Algebra I Grade 9-10

#total non EL
#dat$NonEL<-dat$NonELF + dat$NonELM

algI.sch$NonEL.GS0910 <- algI.sch$NonELF.GS0910 + algI.sch$NonELM.GS0910

non.el.AlgebraGS0910 <- sum(algI.sch$NonEL.GS0910)
non.el.AlgebraGS0910
## [1] 2663848
#There are 2,663,848 Non-English Learners Enrolled in Algebra I G9-10

English Learners in Algebra I in Grade 9-10

English Learner Males in Algebra I

#Total Lep Male in Algebra I 

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

algI.sch$ELM.AIGS0910 <- algI.sch$SCH_ALGENR_GS0910_LEP_M

sum(algI.sch$SCH_ALGENR_GS0910_LEP_M)
## [1] 152844
sum(algI.sch$ELM.AIGS0910)
## [1] 152844
## There is 152,844 English Learner Males in Algebra I Grade 9-10 

English Learner Females in Algebra I Grade 9-10

#Total LEP Female in GT
#dat$ELFGT <- dat$SCH_GTENR_LEP_F

algI.sch$ELF.AIGS0910 <- algI.sch$SCH_ALGENR_GS0910_LEP_F

sum(algI.sch$ELF.AIGS0910)
## [1] 112581
## There are 112,581 EL Females in Algebra I Grade 9-10 Classes 

Total English Learners in Algebra I 9-10

#dat$ELEnrol <- dat$TOT_LEPENR_M + dat$TOT_LEPENR_F

algI.sch$ELEnrolAIGS0910 <- algI.sch$ELM.AIGS0910 + algI.sch$ELF.AIGS0910

els.AIGS0910 <- sum(algI.sch$ELEnrolAIGS0910)

sum(els.AIGS0910)
## [1] 265425
## There is 265,425 English learners in Algebra I Grade 9-10  

Percentage of ELs and Non ELs in Algebra I Grade 9-10 Courses

###Percentage of ELs out of Total LEP HS
round(els.AIGS0910/tot_lep_hs*100,2)
## [1] 24.68
round(els.AIGS0910/els.k12*100,2)
## [1] 5.01
##Non-EL 

round(non.el.AlgebraGS0910/non.el.hs*100,2)
## [1] 20.32
round(non.el.AlgebraGS0910/nonel.k12*100,2)
## [1] 5.84

Grade 11-12 Algebra I

Non-English Learner Male Students Enrolled in Algebra I Courses Grade 11-12

#Computes the total number of a non-English Learner male students in Algebra I courses

#dat$NonELM<- (dat$TOT_ENR_M - dat$TOT_LEPENR_M)

algI.sch$NonELM.GS1112 <- (algI.sch$TOT_ALGENR_GS1112_M - algI.sch$SCH_ALGENR_GS1112_LEP_M)

sum(algI.sch$NonELM.GS1112)
## [1] 116502
#There are 116,502 Non-English Learner Male Students Enrolled in Algebra I Grade 11-12 courses.

Non-English Learner Female Students in Algebra I Grade 11-12

#Total female non-EL 
#dat$NonELF <-dat$TOT_ENR_F-dat$TOT_LEPENR_F

algI.sch$NonELF.GS1112 <- (algI.sch$TOT_ALGENR_GS1112_F - algI.sch$SCH_ALGENR_GS1112_LEP_F)

sum(algI.sch$NonELF.GS1112)
## [1] 87404
#There are 87,404 Non-English Learner Females Enrolled in Algebra I Grade 11-12 courses.

Total Non ELs in Algebra I Grade 11-12

#total non EL
#dat$NonEL<-dat$NonELF + dat$NonELM

algI.sch$NonEL.GS1112 <- algI.sch$NonELF.GS1112 + algI.sch$NonELM.GS1112

non.el.AlgebraGS1112 <- sum(algI.sch$NonEL.GS1112)
non.el.AlgebraGS1112
## [1] 203906
#There are 203,906 Non-English Learners Enrolled in Algebra I Grade 11-12 courses

English Learners in Algebra I in Grade 11-12

English Learner Males in Algebra I

#Total Lep Male in Algebra I 

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

algI.sch$ELM.AIGS1112 <- algI.sch$SCH_ALGENR_GS1112_LEP_M

sum(algI.sch$SCH_ALGENR_GS1112_LEP_M)
## [1] 21569
sum(algI.sch$ELM.AIGS1112)
## [1] 21569
## There is 21,569 English Learner Males in Algebra I Grade 11-12 

English Learner Females in Algebra I Grade 11-12

#Total LEP Female in GT
#dat$ELFGT <- dat$SCH_GTENR_LEP_F

algI.sch$ELF.AIGS1112 <- algI.sch$SCH_ALGENR_GS1112_LEP_F

sum(algI.sch$ELF.AIGS1112)
## [1] 15084
## There are 15,084 EL Females in Algebra I Grade 11-12 Classes 

Total English Learners in Algebra I 11-12

#dat$ELEnrol <- dat$TOT_LEPENR_M + dat$TOT_LEPENR_F

algI.sch$ELEnrolAIGS1112 <- algI.sch$ELM.AIGS1112 + algI.sch$ELF.AIGS1112

els.AIGS1112 <- sum(algI.sch$ELEnrolAIGS1112)

sum(els.AIGS1112)
## [1] 36653
## There is 36,653 English learners in Algebra I Grade 11-12  

Percentage of ELs and Non ELs in Algebra I Grade 11-12 Courses

#Out of HS population

round(els.AIGS1112/tot_lep_hs*100,2)
## [1] 3.41
round(els.AIGS1112/els.k12*100,2)
## [1] 0.69
round(non.el.AlgebraGS1112/non.el.hs*100,2)
## [1] 1.56
#
round(non.el.AlgebraGS1112/nonel.k12*100,2)
## [1] 0.45

Total Enrollment Grades 8-12 in Algebra I

##

sum(els.AIGS0910 + els.AIGS1112)
## [1] 302078
## Percentage of Els in Algebra I 9-12

sum( els.AIGS0910 + els.AIGS1112)/tot_lep_hs*100
## [1] 28.08917
##Out of ALl ELs

sum(els.AIGS0910 + els.AIGS1112)/els.k12*100
## [1] 5.702973
#Percentage of Non-Els in Algebra 9-12

sum(non.el.AlgebraGS0910 + non.el.AlgebraGS1112) 
## [1] 2867754
(non.el.AlgebraGS0910 + non.el.AlgebraGS1112) / non.el.hs*100
## [1] 21.87779
(non.el.AlgebraGS0910 + non.el.AlgebraGS1112) / nonel.k12*100
## [1] 6.285428