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

filealgII <- "Algebra II.csv"

algII.sch <- read.csv(filealgII)

### 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_MATHENR_ALG2_M Students Enrolled in Algebra II: Calculated Male Total TOT_MATHENR_ALG2_F Students Enrolled in Algebra II: Calculated Female Total SCH_MATHENR_ALG2_LEP_M Students Enrolled in Algebra II: LEP Male SCH_MATHENR_ALG2_LEP_F Students Enrolled in Algebra II: LEP Female

Change Code from 0s to 9s

#Code to change the -9s to 0s

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

Algebra II

Non-English Learner Male Students Enrolled in Algebra II Courses

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

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

algII.sch$NonELM <- (algII.sch$TOT_MATHENR_ALG2_M - algII.sch$SCH_MATHENR_ALG2_LEP_M)

sum(algII.sch$NonELM)
## [1] 1405310
#There are 1,405,310 Non-English Learner Male Students Enrolled in Algebra II  

Non-English Learner Female Students in Algebra II

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

algII.sch$NonELF <- (algII.sch$TOT_MATHENR_ALG2_F - algII.sch$SCH_MATHENR_ALG2_LEP_F)

sum(algII.sch$NonELF)
## [1] 1451562
#There are 1,451,562 Non-English Learner Females Enrolled in Algebra II  courses.

Total Non ELs in Algebra II

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

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

non.el.Algeb2 <- sum(algII.sch$NonEL)
non.el.Algeb2
## [1] 2856872
#There are 2,856,872 Non-English Learners Enrolled in Algebra II 

English Learners in Algebra II in

English Learner Males in Algebra II

#Total Lep Male in Algebra II 

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

algII.sch$ELM.Algeb2 <- algII.sch$SCH_MATHENR_ALG2_LEP_M

sum(algII.sch$SCH_MATHENR_ALG2_LEP_M)
## [1] 74356
sum(algII.sch$ELM.Algeb2)
## [1] 74356
## There is 74,356 English Learner Males in Algebra II  

English Learner Females in Algebra II

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

algII.sch$ELF.Algeb2 <- algII.sch$SCH_MATHENR_ALG2_LEP_F

sum(algII.sch$ELF.Algeb2)
## [1] 64337
## There are 64,337 EL Females in Algebra II  Classes 

Total English Learners in Algebra II

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

algII.sch$ELEnrolAlgeb2<- algII.sch$ELM.Algeb2 + algII.sch$ELF.Algeb2

els.Algeb2 <- sum(algII.sch$ELEnrolAlgeb2)

sum(els.Algeb2)
## [1] 138693
## There is 138,693 English learners in Algebra II   

Percentage of ELs and Non ELs in Algebra II Courses

round(els.Algeb2/tot_lep_hs*100,2)
## [1] 12.9
round(els.Algeb2/els.k12*100,2)
## [1] 2.62
round(non.el.Algeb2/non.el.hs*100,2)
## [1] 21.79
round(non.el.Algeb2/nonel.k12*100,2)
## [1] 6.26