-
Notifications
You must be signed in to change notification settings - Fork 1
/
Massachusetts_Data_LONG_2022.R
63 lines (43 loc) · 3.04 KB
/
Massachusetts_Data_LONG_2022.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
################################################################
### ###
### Create 2022 LONG data from completed Data ###
### ###
################################################################
### Load libraries
require(data.table)
require(foreign)
### Load data
tmp.math <- as.data.table(read.spss("Data/Base_Files/Math17_22.sav", to.data.frame=TRUE, trim.factor.names=TRUE))
tmp.ela <- as.data.table(read.spss("Data/Base_Files/ELA17_22.sav", to.data.frame=TRUE, trim.factor.names=TRUE))
tmp.math[,content_area:="MATHEMATICS"]
tmp.ela[,content_area:="ELA"]
Massachusetts_Data_LONG_2017_to_2022 <- rbindlist(list(tmp.math, tmp.ela))
### Tidy up data
setnames(Massachusetts_Data_LONG_2017_to_2022, toupper(names(Massachusetts_Data_LONG_2017_to_2022)))
setnames(Massachusetts_Data_LONG_2017_to_2022, "SCALE_SCORE2", "SCALE_SCORE_ACTUAL")
setnames(Massachusetts_Data_LONG_2017_to_2022, "SCALE_SCORE_STANDARD_ERROR", "SCALE_SCORE_CSEM")
Massachusetts_Data_LONG_2017_to_2022[,GRADE:=as.character(as.numeric(GRADE))]
Massachusetts_Data_LONG_2017_to_2022[,ACHIEVEMENT_LEVEL:=as.factor(ACHIEVEMENT_LEVEL)]
levels(Massachusetts_Data_LONG_2017_to_2022$ACHIEVEMENT_LEVEL) <- c("Level 1", "Level 2", "Level 3", "Level 4")
Massachusetts_Data_LONG_2017_to_2022[,ACHIEVEMENT_LEVEL:=as.character(ACHIEVEMENT_LEVEL)]
Massachusetts_Data_LONG_2017_to_2022[,YEAR:=as.character(YEAR)]
Massachusetts_Data_LONG_2017_to_2022[,ASSESSMENT_PROGRAM:=NULL]
Massachusetts_Data_LONG_2017_to_2022[,MODE:=as.factor(MODE)]
levels(Massachusetts_Data_LONG_2017_to_2022$MODE) <- c("Online", "Paper", "Remote")
Massachusetts_Data_LONG_2017_to_2022[,MODE:=as.character(MODE)]
Massachusetts_Data_LONG_2017_to_2022[,ACHIEVEMENT_LEVEL_ORIGINAL:=as.factor(ACHIEVEMENT_LEVEL_ORIGINAL)]
levels(Massachusetts_Data_LONG_2017_to_2022$ACHIEVEMENT_LEVEL_ORIGINAL) <- c("Advanced", "Exceeding", "Meeting", "Needs Improvement", "Not Meeting", "Partially Meeting", "Proficient", "Warning/Failing", "Warning/Failing")
Massachusetts_Data_LONG_2017_to_2022[,ACHIEVEMENT_LEVEL_ORIGINAL:=as.character(ACHIEVEMENT_LEVEL_ORIGINAL)]
Massachusetts_Data_LONG_2017_to_2022[,VALID_CASE:="VALID_CASE"]
### Setkey and look for duplicates
setkey(Massachusetts_Data_LONG_2017_to_2022, VALID_CASE, CONTENT_AREA, YEAR, GRADE, ID)
table(duplicated(Massachusetts_Data_LONG_2017_to_2022, by=key(Massachusetts_Data_LONG_2017_to_2022)))
### Reorder columns
my.order <- c("VALID_CASE", "CONTENT_AREA", "YEAR", "GRADE", "ID", "SCALE_SCORE", "ACHIEVEMENT_LEVEL", "SCALE_SCORE_CSEM",
"SCALE_SCORE_ORIGINAL", "ACHIEVEMENT_LEVEL_ORIGINAL", "SCALE_SCORE_ACTUAL", "MODE")
setcolorder(Massachusetts_Data_LONG_2017_to_2022, my.order)
### Create 2021 Data
Massachusetts_Data_LONG_2022 <- Massachusetts_Data_LONG_2017_to_2022[YEAR=="2022"]
### Save results
save(Massachusetts_Data_LONG_2022, file="Data/Massachusetts_Data_LONG_2022.Rdata")
save(Massachusetts_Data_LONG_2017_to_2022, file="Data/Massachusetts_Data_LONG_2017_to_2022.Rdata")