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

fileGeom <- "Geometry.csv"

geom.sch <- read.csv(fileGeom)

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

Change Code from 0s to 9s

#Code to change the -9s to 0s

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

## important columns 27:30

Non-English Learner Male Students in Geometry

#Computes the total number of a non-English Learner male students in pre school 

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

geom.sch$NonELM <- (geom.sch$TOT_MATHENR_GEOM_M - geom.sch$SCH_MATHENR_GEOM_LEP_M)

sum(geom.sch$NonELM)
## [1] 1615556
# 1,615,556 Non English learner males in Geometery

Non-English Learner Female Students in Geometry

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

geom.sch$NonELF <- (geom.sch$TOT_MATHENR_GEOM_F - geom.sch$SCH_MATHENR_GEOM_LEP_F)

sum(geom.sch$NonELF)
## [1] 1597543
## There are 1,597,543 Non English Learner Females in Geometry 

Total Non ELs in Geometry

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

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

non.el.geom <- sum(geom.sch$NonEL)

#There are 3,213,099 non english learners in Geometry

English Learners in Geometry

English Learner Males in Geometry

#Total Lep Male in Geometry

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

geom.sch$ELMGEOM <- geom.sch$SCH_MATHENR_GEOM_LEP_M

sum(geom.sch$ELMGEOM)
## [1] 123758
#There are 123,758 English learner males in Geometry 

English Learner Females in Geometry

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

geom.sch$ELFGEOM <- geom.sch$SCH_MATHENR_GEOM_LEP_F

sum(geom.sch$ELFGEOM)
## [1] 97156
#There are 97,156 English learner females in Geometry 

Total English Learners in Geometry

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

geom.sch$ELEnrolGEOM <- geom.sch$ELMGEOM + geom.sch$ELFGEOM

els.geom <- sum(geom.sch$ELEnrolGEOM)

#There are 220,914 English learners in Geometry 

#There are 3,213,099 non english learners in Geometry

Percentages

Computes the percentage of Male English Learners at the school level who are enrolled in Geometry

# Computes the percentage of male English Learners at the school level who are enrolled in a G&T program

#dat$ELMGTPct<-round(dat$SCH_GTENR_LEP_M/dat$TOT_LEPENR_M*100,1)

geom.sch$ELMPct <- round(geom.sch$ELMGEOM/geom.sch$NonELM*100,1)

Computes the percentage of Female English Learners at the school level who are enrolled in Geometry

# Computes the percentage of female English Learners at the school level who are enrolled in a G&T program
#dat$ELFGTPct<-round(dat$SCH_GTENR_LEP_F/dat$TOT_LEPENR_F*100,1)

geom.sch$ELFPct <- round(geom.sch$ELFGEOM/geom.sch$NonELF*100,1)

Computes the percentage of male non-English Learners at the school level who are enrolled in a Geometry program

#dat$NonELMGTPct<-round(dat$NonELMGT/dat$NonELM*100,1)

geom.sch$NonELMGEOMPct <- round(geom.sch$ELMGEOM/geom.sch$NonELM*100,1)

Percentage of English Learners in Geometry

######################

#Percentage of ELs in Geometry in all ELs in High School

(els.geom)/tot_lep_hs*100
## [1] 20.54202
############################

#Percentage of English Learners (Number of ELs in Geom / Number of English Learners Total K-12)

(els.geom)/els.k12*100 
## [1] 4.170667
### 4.2% of all English Learners are enrolled in Geometry  


######################

#Percentage of ELs in Geometry in all ELs in High School

(els.geom)/tot_lep_hs*100
## [1] 20.54202

#Non English Learners in Geometry

## Percentage of ELs in Geometry / All - non ELs in High School

non.el.geom/non.el.hs*100
## [1] 24.51239
## Percentage of Els in Geom / All non-ELs in K-12

non.el.geom/nonel.k12*100
## [1] 7.042341
## Percentage of ELs in Geometry / All - non ELs in High School

non.el.geom/non.el.hs*100
## [1] 24.51239
TOT_students_Geom <- sum(geom.sch$TOT_MATHENR_GEOM_F+geom.sch$TOT_MATHENR_GEOM_M)


els.geom/TOT_students_Geom*100
## [1] 6.433115
non.el.geom/TOT_students_Geom*100
## [1] 93.56689