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 Gifted and Talented File -- with only the columns needed

fileGT <- "Gifted and Talented_CRDC_2017-18.csv"

GT.sch <- read.csv(fileGT)

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

GT.sch[GT.sch==-8]<-0
GT.sch[GT.sch==-9]<-0
GT.sch[GT.sch==-8]<-0
GT.sch[GT.sch==-6]<-0
GT.sch[GT.sch==-5]<-0
GT.sch[GT.sch==-3]<-0

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_GTENR_M Gifted and Talented Student Enrollment: Calculated Male Total TOT_GTENR_F Gifted and Talented Student Enrollment: Calculated Female Total SCH_GTENR_LEP_M Gifted and Talented Student Enrollment: LEP Male SCH_GTENR_LEP_F Gifted and Talented Student Enrollment: LEP Female

Change Code from 0s to 9s

#Code to change the -9s to 0s

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

## important columns 27:30

Non-English Learner Male Students in Gifted and Talented

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

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

GT.sch$NonELM <- (GT.sch$TOT_GTENR_M - GT.sch$SCH_GTENR_LEP_M)

sum(GT.sch$NonELM)
## [1] 1618641
# 1,618,641 Non English learner males in GT

Non-English Learner Female Students in Gifted and Talented

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

GT.sch$NonELF <- (GT.sch$TOT_GTENR_F - GT.sch$SCH_GTENR_LEP_F)

sum(GT.sch$NonELF)
## [1] 1630767
## There are 1,630,767 Non English Learner Females in Gifted and Talented 

Total Non ELs in Gifted and Talented

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

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

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

non.el.GT
## [1] 3249408
#There are 3,249,408 non english learners in Gifted and Talented

English Learners in Gifted and Talented

English Learner Males in Gifted and Talented

#Total Lep Male in Gifted and Talented

#dat$ELMGT <- dat$SCH_GTENR_LEP_M

GT.sch$ELMGEOM <- GT.sch$SCH_GTENR_LEP_M

sum(GT.sch$ELMGEOM)
## [1] 42932
#There are 42,932 English learner males in Gifted and Talented 

English Learner Females in Gifted and Talented

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

GT.sch$ELFGEOM <- GT.sch$SCH_GTENR_LEP_F

sum(GT.sch$ELFGEOM)
## [1] 37200
#There are 37,200 English learner females in Gifted and Talented 

Total English Learners in Gifted and Talented

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

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

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

els.GT
## [1] 80132
#There are 80,132 English learners in Gifted and Talented 

Percentages

Computes the percentage of Male English Learners at the school level who are enrolled in Gifted and Talented

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

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

Computes the percentage of Female English Learners at the school level who are enrolled in Gifted and Talented

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

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

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

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

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

Percentage of English Learners in Gifted and Talented

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

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

(els.GT)/els.k12*100 
## [1] 1.512823
### 1.5% of all English Learners are enrolled in Gifted and Talented  


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

#Non English Learners in Gifted and Talented

## Percentage of Els in GT / All non-ELs in K-12

non.el.GT/nonel.k12*100
## [1] 7.121922
##7.12% of Non-Els are in GT.