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

setwd("C:/Users/BlaiseSevier/Desktop/R Work")

fileGT <- "Gifted and Talented_Cali.csv"

GT.sch <- read.csv(fileGT)

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

fileCA <- "fs141cali.csv"

CA.Enrol.k12 <- read.csv(fileCA)


### How to set your working directory 
## In quotation marks, ("C: /Users/BlaiseSevier/Desktop/R Work")

#################### Change code from negative numbers to 0s 

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


# Reserve code value
# Definition
# -3 | Skip Logic Failure
# -5 | Action Plan
# -6 | Force Certified
# -8 | EDFacts Missing Data
# -9 | Not Applicable / Skipped
# -11 | Suppressed Data

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

## From FS 141



num.k12.el.CA <- sum(CA.Enrol.k12$Value)

## From NCES All Enrollment Data

num.k12.non.el.CA <- 6304266 - num.k12.el.CA


#1197286

Non-English Learner Male Students in Gifted and Talented in California

#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] 184182
# 1,618,641 Non English learner males in GT in the US

#184,182 Non El Males in California 

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] 186611
## There are 1,630,767 Non English Learner Females in Gifted and Talented in the uS

# There are 186,611 Non English Learner Females in Gifted and Talented in California

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] 370793
#There are 3,249,408 non english learners in Gifted and Talented in the US

# There are 370,793 non english learners in Gifted and Talented in California

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] 4880
#There are 42,932 English learner males in Gifted and Talented in the US

# there are 4,880 English learner males in Gifted and Talented in California

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] 3708
#There are 37,200 English learner females in Gifted and Talented  in the US

#There are 3,708  English learner females in Gifted and Talented in California

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] 8588
#There are 80,132 English learners in Gifted and Talented 

# There are 8,588  English learners in Gifted and Talented in California

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)/num.k12.el.CA*100 
## [1] 0.7172889
### 1.5% of all English Learners are enrolled in Gifted and Talented  in the US

###0.71% of all English Learners are enrolled in Gifted and Talented in California!!!!! 



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

#Non English Learners in Gifted and Talented

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

non.el.GT/(num.k12.non.el.CA)*100
## [1] 7.260514
non.el.GT
## [1] 370793
#There are 370,793 non-ELs in Gifted and Talented Programs in California out of 5,106,980 non-Els in California k-12

##7.12% of Non-Els are in GT in the USA 

### 7.3% of non-ELs are in GT in California