Reading the Datafile in R

#Invoking Required Libraries
library(foreign)
library(tidyverse)
library(dplyr)
library(ggplot2)
library(pander)
library(readxl)

# Uploading the Given Data
D_data <- read.spss("Duplicate_data.sav", to.data.frame=TRUE)

#Changing the data into a data frame
D_data <- as.data.frame(D_data)

# Checking the variable types in the data D_data
    #str(D_data)

# All other variables have accurate data types but the Student_Id. Thus, changing the data in this columns to a factor type
D_data$Std_ID <- as.factor(D_data$Std_ID)
    #str(D_data)

#Checking the Last cases of the data
tail(D_data)
             Std_ID Gender        Grade Teacher Attendance Wordsread
8  Student 10         Male Fourth Grade  Oliver         18     21316
9  Student 11       Female Fourth Grade  Oliver         18     19662
10 Student 13         Male  Fifth Grade  Turner         14     30453
11 Student 14       Female  Fifth Grade  Turner         17     31066
12 Student 15       Female  Fifth Grade  Turner         16     48149
13 Student 17       Female  Fifth Grade  Gunter         18     36191
   MARSIGRSPre MARSIGRSPost MARSIPSSPre MARSIPSSPost MARSISRSPre MARSISRSPost
8          2.6          3.8         2.2          4.2         3.4          2.8
9          1.2          3.4         3.4          3.6         3.2          3.2
10         2.2          4.0         4.4          4.6         3.8          4.2
11         3.2          4.2         4.6          4.6         4.4          4.6
12         3.4          3.4         4.8          4.8         4.6          4.2
13         3.4          3.0         4.0          4.6         5.0          4.2
   MARSITotalPre MARSITotalPost
8           2.73           3.60
9           2.60           3.40
10          3.46           4.26
11          4.06           4.46
12          4.26           4.13
13          4.13           3.93
# Summarizing the Data (Descriptive Analysis)
summary(D_data[1:6])
              Std_ID     Gender           Grade     Teacher    Attendance   
 Student 1       :1   Male  :4   Third Grade :5   Luna  :5   Min.   :14.00  
 Student 10      :1   Female:9   Fourth Grade:4   Oliver:4   1st Qu.:15.00  
 Student 11      :1              Fifth Grade :4   Gunter:1   Median :17.00  
 Student 13      :1                               Turner:3   Mean   :16.38  
 Student 14      :1                                          3rd Qu.:18.00  
 Student 15      :1                                          Max.   :18.00  
 (Other)         :7                                                         
   Wordsread     
 Min.   : 16631  
 1st Qu.: 21316  
 Median : 31066  
 Mean   : 37261  
 3rd Qu.: 38867  
 Max.   :108885  
                 
# Changing Wide to Long data Creating a new Key-variable 'test_type' having 'pretest' and 'posttest' and collapsing data into a long format (for Global Reading Strategies)
GRS_data <- gather(D_data, key=test_type, value = average_GRS_scores, MARSIGRSPre:MARSIGRSPost, factor_key=TRUE)

#Truncating the data for Required Columns
GRS_data_final <- select(GRS_data, c(1:6, 13,14))
head(GRS_data_final)
            Std_ID Gender        Grade Teacher Attendance Wordsread   test_type
1 Student 1        Female  Third Grade    Luna         16     51858 MARSIGRSPre
2 Student 2        Female  Third Grade    Luna         18     28575 MARSIGRSPre
3 Student 4          Male  Third Grade    Luna         17     38867 MARSIGRSPre
4 Sudent 5         Female  Third Grade    Luna         14     33160 MARSIGRSPre
5 Student 6        Female  Third Grade    Luna         15    108885 MARSIGRSPre
6 Student 7        Female Fourth Grade  Oliver         17     16631 MARSIGRSPre
  average_GRS_scores
1                2.4
2                1.8
3                3.4
4                3.0
5                3.4
6                1.6
    #str(GRS_data_final)

#Saving the GRS_data as a separate dataset in my local disc
write.csv(GRS_data_final, file = "GRS_data_final.csv", row.names = FALSE)

For Problem-Solving Strategies

PSS_data <- gather(D_data, key=test_type, value = average_PSS_scores, MARSIPSSPre:MARSIPSSPost, factor_key=TRUE)
    #head(PSS_data)
#Truncating the data for Required Columns
PSS_data_final <- select(PSS_data, c(1:6, 13,14))
head(PSS_data_final)
            Std_ID Gender        Grade Teacher Attendance Wordsread   test_type
1 Student 1        Female  Third Grade    Luna         16     51858 MARSIPSSPre
2 Student 2        Female  Third Grade    Luna         18     28575 MARSIPSSPre
3 Student 4          Male  Third Grade    Luna         17     38867 MARSIPSSPre
4 Sudent 5         Female  Third Grade    Luna         14     33160 MARSIPSSPre
5 Student 6        Female  Third Grade    Luna         15    108885 MARSIPSSPre
6 Student 7        Female Fourth Grade  Oliver         17     16631 MARSIPSSPre
  average_PSS_scores
1                3.0
2                4.0
3                2.6
4                4.4
5                3.8
6                3.8
#Saving the PSS_data as a separate dataset in my local disc
write.csv(PSS_data_final, file = "PSS_data_final.csv", row.names = FALSE)

For support-reading Strategies

SRS_data <- gather(D_data, key=test_type, value = average_SRS_scores, MARSISRSPre:MARSISRSPost, factor_key=TRUE)
  #head(SRS_data)

 #Truncating the data for Required Columns
SRS_data_final <- select(SRS_data, c(1:6, 13,14))
    head(SRS_data_final)
            Std_ID Gender        Grade Teacher Attendance Wordsread   test_type
1 Student 1        Female  Third Grade    Luna         16     51858 MARSISRSPre
2 Student 2        Female  Third Grade    Luna         18     28575 MARSISRSPre
3 Student 4          Male  Third Grade    Luna         17     38867 MARSISRSPre
4 Sudent 5         Female  Third Grade    Luna         14     33160 MARSISRSPre
5 Student 6        Female  Third Grade    Luna         15    108885 MARSISRSPre
6 Student 7        Female Fourth Grade  Oliver         17     16631 MARSISRSPre
  average_SRS_scores
1                2.8
2                2.0
3                3.0
4                4.0
5                3.6
6                3.6
#Saving the SRS_data as a separate dataset in my local disc
write.csv(SRS_data_final, file = "SRS_data_final.csv", row.names = FALSE)

For total scores

total_data <- gather(D_data, key=test_type, value = average_total_scores, MARSITotalPre:MARSITotalPost, factor_key=TRUE)
head(total_data)
            Std_ID Gender        Grade Teacher Attendance Wordsread MARSIGRSPre
1 Student 1        Female  Third Grade    Luna         16     51858         2.4
2 Student 2        Female  Third Grade    Luna         18     28575         1.8
3 Student 4          Male  Third Grade    Luna         17     38867         3.4
4 Sudent 5         Female  Third Grade    Luna         14     33160         3.0
5 Student 6        Female  Third Grade    Luna         15    108885         3.4
6 Student 7        Female Fourth Grade  Oliver         17     16631         1.6
  MARSIGRSPost MARSIPSSPre MARSIPSSPost MARSISRSPre MARSISRSPost     test_type
1          3.2         3.0          3.0         2.8          2.8 MARSITotalPre
2          3.4         4.0          5.0         2.0          4.2 MARSITotalPre
3          4.0         2.6          2.6         3.0          3.0 MARSITotalPre
4          3.2         4.4          3.8         4.0          3.4 MARSITotalPre
5          3.2         3.8          3.8         3.6          4.2 MARSITotalPre
6          2.6         3.8          3.0         3.6          4.0 MARSITotalPre
  average_total_scores
1                 2.73
2                 2.60
3                 3.00
4                 3.80
5                 3.80
6                 3.00
 #Truncating the data for Required Columns
total_data_final <- select(total_data, c(1:6, 13,14))
    head(total_data_final)
            Std_ID Gender        Grade Teacher Attendance Wordsread
1 Student 1        Female  Third Grade    Luna         16     51858
2 Student 2        Female  Third Grade    Luna         18     28575
3 Student 4          Male  Third Grade    Luna         17     38867
4 Sudent 5         Female  Third Grade    Luna         14     33160
5 Student 6        Female  Third Grade    Luna         15    108885
6 Student 7        Female Fourth Grade  Oliver         17     16631
      test_type average_total_scores
1 MARSITotalPre                 2.73
2 MARSITotalPre                 2.60
3 MARSITotalPre                 3.00
4 MARSITotalPre                 3.80
5 MARSITotalPre                 3.80
6 MARSITotalPre                 3.00
#Saving the total_data as a separate dataset in my local disc
write.csv(total_data_final, file = "total_data_final.csv", row.names = FALSE)

I further manipulated the data. I merged all of the saved data into a single Excel file using the following syntax.

# Joining GRS table to PSS table
merged_data <- read_excel("merged_data.xlsx")
merged_data <- as.data.frame(merged_data)
head(merged_data)
     Std_ID Gender        Grade Teacher Attendance Wordsread test_type
1 Student 1 Female  Third Grade    Luna         16     51858 MARSI_Pre
2 Student 2 Female  Third Grade    Luna         18     28575 MARSI_Pre
3 Student 4   Male  Third Grade    Luna         17     38867 MARSI_Pre
4  Sudent 5 Female  Third Grade    Luna         14     33160 MARSI_Pre
5 Student 6 Female  Third Grade    Luna         15    108885 MARSI_Pre
6 Student 7 Female Fourth Grade  Oliver         17     16631 MARSI_Pre
  GRS_scores PSS_scores SRS_scores total_scores
1        2.4        3.0        2.8         2.73
2        1.8        4.0        2.0         2.60
3        3.4        2.6        3.0         3.00
4        3.0        4.4        4.0         3.80
5        3.4        3.8        3.6         3.80
6        1.6        3.8        3.6         3.00

Section Two: Getting Data Ready for stabda5d Analyis

stabda5d <- read.spss("Overton Summer 2021 School Data.sav")
stabda5d <- as.data.frame(stabda5d)
str(stabda5d)
'data.frame':   20 obs. of  112 variables:
 $ LastName                : Factor w/ 20 levels "Bobbitt","Boney",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ FirstName               : Factor w/ 20 levels "Makynna","Hattie",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ Gender                  : Factor w/ 2 levels "Male","Female": 2 2 2 1 2 2 2 1 1 1 ...
 $ Ethnicity               : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Grade                   : Factor w/ 3 levels "Third Grade",..: 1 1 1 1 1 1 2 2 2 2 ...
 $ Teacher                 : Factor w/ 4 levels "Maryanna Luna",..: 1 1 1 1 1 1 2 2 2 2 ...
 $ Attendance              : num  16 18 11 17 14 15 17 10 15 18 ...
 $ Wordsread               : num  51858 28575 49406 38867 33160 ...
 $ MARSIGRSPre             : num  2.4 1.8 3.2 3.4 3 3.4 1.6 2.2 3.4 2.6 ...
 $ MARSIGRSPost            : num  3.2 3.4 NA 4 3.2 3.2 2.6 NA 5 3.8 ...
 $ MARSIPSSPre             : num  3 4 3.4 2.6 4.4 3.8 3.8 2 4 2.2 ...
 $ MARSIPSSPost            : num  3 5 NA 2.6 3.8 3.8 3 NA 5 4.2 ...
 $ MARSISRSPre             : num  2.8 2 3 3 4 3.6 3.6 3.6 4.2 3.4 ...
 $ MARSISRSPost            : num  2.8 4.2 NA 3 3.4 4.2 4 NA 5 2.8 ...
 $ MARSITotalPre           : num  2.73 2.6 3.2 3 3.8 3.8 3 2.6 3.86 2.73 ...
 $ MARSITotalPost          : num  3 4.2 NA 3.2 3.46 3.73 3.2 NA 5 3.6 ...
 $ GRADEWRRawPre           : num  27 28 23 28 24 28 NA NA NA NA ...
 $ GRADEWRRawPost          : num  28 29 NA 30 24 26 NA NA NA NA ...
 $ GRADEWRStaninePre       : num  4 5 3 5 3 5 NA NA NA NA ...
 $ GRADEWRStaninePost      : num  5 6 NA 8 3 4 NA NA NA NA ...
 $ GRADEWRGEPre            : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRGEPost           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRSSPre            : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRSSPost           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRNCEPre           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRNCEPost          : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRGSVPre           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEWRGSVPost          : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEVocRSPre           : num  20 16 15 7 14 21 19 15 19 15 ...
 $ GRADEVocRSPost          : num  12 18 NA 6 15 NA 14 NA 17 13 ...
 $ GRADEVocStaninePre      : num  5 4 4 2 3 5 4 4 4 3 ...
 $ GRADEVocStaninePost     : num  3 4 NA 1 4 NA 4 NA 5 4 ...
 $ GRADEVocGEPre           : num  NA NA NA NA NA NA 4.2 3.4 4.2 3.4 ...
 $ GRADEVocGEPost          : num  NA NA NA NA NA NA 3.2 NA 3.8 3 ...
 $ GRADEVocSSPre           : num  NA NA NA NA NA NA 95 93 95 87 ...
 $ GRADEVocSSPost          : num  NA NA NA NA NA NA 91 NA 96 89 ...
 $ GRADEVocNCEPre          : num  NA NA NA NA NA NA 43 40 43 32 ...
 $ GRADEVocNCEPost         : num  NA NA NA NA NA NA 37 NA 44 35 ...
 $ GRADEVocGSVPre          : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEVocGSVPost         : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEVocCompRSPre       : num  47 44 38 35 38 49 NA NA NA NA ...
 $ GRADEVocCompRSPost      : num  40 47 NA 36 39 NA NA NA NA NA ...
 $ GRADEVocCompStaninePre  : num  5 4 3 2 3 5 NA NA NA NA ...
 $ GRADEVocCompStaninePost : num  3 5 NA 3 3 NA NA NA NA NA ...
 $ GRADEVocCompGEPre       : num  2.5 2.3 2 1.9 2 2.7 NA NA NA NA ...
 $ GRADEVocCompGEPost      : num  2.1 2.5 NA 1.9 2 NA NA NA NA NA ...
 $ GRADEVocCompSSPre       : num  97 93 86 82 86 100 NA NA NA NA ...
 $ GRADEVocCompSSPost      : num  88 96 NA 83 86 NA NA NA NA NA ...
 $ GRADEVocCompNCEPre      : num  46 40 30 25 30 50 NA NA NA NA ...
 $ GRADEVocCompNCEPost     : num  33 44 NA 26 30 NA NA NA NA NA ...
 $ GRADEVocCompGSVPre      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEVocCompGSVPost     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompRSPre       : num  14 14 10 8 13 15 13 8 15 13 ...
 $ GRADESenCompRSPost      : num  9 17 NA 8 12 NA 13 NA 12 10 ...
 $ GRADESenCompStaninePre  : num  4 4 3 2 4 4 5 3 5 5 ...
 $ GRADESenCompStaninePost : num  3 4 NA 2 3 NA 5 NA 4 4 ...
 $ GRADESenCompGEPre       : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompGEPost      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompSSPre       : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompSSPost      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompNCEPre      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompNCEPost     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompGSVPre      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADESenCompGSVPost     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompRSPre      : num  9 9 8 6 11 12 12 11 10 14 ...
 $ GRADEPassCompRSPost     : num  9 17 NA 4 14 NA 18 NA 11 11 ...
 $ GRADEPassCompStaninePre : num  3 3 3 2 4 4 4 4 3 5 ...
 $ GRADEPassCompStaninePost: num  3 5 NA 1 4 NA 5 NA 4 4 ...
 $ GRADEPassCompGEPre      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompGEPost     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompSSPre      : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompSSPost     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompNCEPre     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompNCEPost    : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompGSVPre     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADEPassCompGSVPost    : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADECompCompRSPre      : num  23 23 18 14 24 27 25 19 25 27 ...
 $ GRADECompCompRSPost     : num  18 34 NA 12 26 NA 31 NA 23 21 ...
 $ GRADECompCompStaninePre : num  3 3 3 2 4 4 4 3 4 4 ...
 $ GRADECompCompStaninePost: num  3 5 NA 2 4 NA 5 NA 4 4 ...
 $ GRADECompCompGEPre      : num  2.1 2.1 1.8 1.5 2.2 2.5 3.4 2.6 3.4 3.7 ...
 $ GRADECompCompGEPost     : num  1.8 3.4 NA 1.3 2.4 NA 4.4 NA 3.1 2.9 ...
 $ GRADECompCompSSPre      : num  88 88 82 77 90 93 90 88 90 92 ...
 $ GRADECompCompSSPost     : num  82 102 NA 74 92 NA 102 NA 93 91 ...
 $ GRADECompCompNCEPre     : num  33 33 25 18 36 40 36 33 36 39 ...
 $ GRADECompCompNCEPost    : num  25 53 NA 13 39 NA 53 NA 40 37 ...
 $ GRADECompCompGSVPre     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADECompCompGSVPost    : num  NA NA NA NA NA NA NA NA NA NA ...
 $ GRADETotalTRSPre        : num  70 67 56 49 62 76 44 34 44 42 ...
 $ GRADETotalTRSPost       : num  58 81 NA 48 65 NA 45 NA 40 34 ...
 $ GRADETotalTStaninePre   : num  4 4 3 2 3 5 4 4 4 4 ...
 $ GRADETotalTStaninePost  : num  3 5 NA 2 4 NA 5 NA 4 4 ...
 $ GRADETotalTGEPre        : num  2.4 2.3 2 1.8 2.1 2.7 3.7 2.8 3.7 3.5 ...
 $ GRADETotalTGEPost       : num  2 3.1 NA 1.8 2.2 NA 3.8 NA 3.3 2.8 ...
 $ GRADETotalTSSPre        : num  92 90 84 79 87 96 91 90 91 90 ...
 $ GRADETotalTSSPost       : num  84 100 NA 78 89 NA 98 NA 95 90 ...
 $ GRADETotalTNCEPre       : num  39 36 28 21 32 44 37 36 37 36 ...
 $ GRADETotalTNCEPost      : num  28 50 NA 19 35 NA 47 NA 43 36 ...
 $ GRADETotalTGSVPre       : num  406 401 385 375 394 415 434 417 434 430 ...
  [list output truncated]

Selecting Required Variables

library(tidyverse)
library(dplyr)
stabda5d_truncated <- select(stabda5d,"Gender","Grade", "Attendance", "Wordsread","GRADETotalTSSPre","GRADETotalTSSPost","GRADETotalTNCEPre","GRADETotalTNCEPost","GRADETotalTGSVPre","GRADETotalTGSVPost")
  #stabda5d_truncated
# Creating an ID Variable
stabda5d_truncated$Std_ID <- paste("Student", 1:20)
# Putting them in Order
stabda5d_truncated <- select(stabda5d_truncated,"Std_ID","Gender","Grade", "Attendance", "Wordsread","GRADETotalTSSPre","GRADETotalTSSPost","GRADETotalTNCEPre","GRADETotalTNCEPost","GRADETotalTGSVPre","GRADETotalTGSVPost")
# Checking the New Data set
  #stabda5d_truncated

Rows 3,6,8,12,18,19, & 20 have missing values in them. As this is a small sample size, we are going to get rid of these data points.

# Getting Rid of selected Rows 
stabda5d_truncated <- stabda5d_truncated[-c(3,6,8,12,18,19,20),]
# Checking
  #stabda5d_truncated

Looks like we got rid of the selected rows from our dataset. Now, We are changing the names of Columns, the dependent variables into more descriptive ones.

colnames(stabda5d_truncated) <-c("Std_ID","Gender","Grade", "Attendance", "Wordsread","Test_Standard_Score_Pre", "Test_Standard_Score_Post", "National_Curve_Equivalent_Pre", "National_Curve_Equivalent_Post","Growth_Scale_Pre","Growth_Scale_Post")
stabda5d_truncated
       Std_ID Gender        Grade Attendance Wordsread Test_Standard_Score_Pre
1   Student 1 Female  Third Grade         16     51858                      92
2   Student 2 Female  Third Grade         18     28575                      90
4   Student 4   Male  Third Grade         17     38867                      79
5   Student 5 Female  Third Grade         14     33160                      87
7   Student 7 Female Fourth Grade         17     16631                      91
9   Student 9   Male Fourth Grade         15     19578                      91
10 Student 10   Male Fourth Grade         18     21316                      90
11 Student 11 Female Fourth Grade         18     19662                      82
13 Student 13   Male  Fifth Grade         14     30453                      84
14 Student 14 Female  Fifth Grade         17     31066                      79
15 Student 15 Female  Fifth Grade         17     71353                      84
16 Student 16 Female  Fifth Grade         16     48149                     104
17 Student 17 Female  Fifth Grade         18     36191                      97
   Test_Standard_Score_Post National_Curve_Equivalent_Pre
1                        84                            39
2                       100                            36
4                        78                            21
5                        89                            32
7                        98                            37
9                        95                            37
10                       90                            36
11                       91                            25
13                       88                            28
14                       92                            21
15                       92                            28
16                      105                            56
17                       90                            46
   National_Curve_Equivalent_Post Growth_Scale_Pre Growth_Scale_Post
1                              28              406               387
2                              50              401               423
4                              19              375               372
5                              35              394               398
7                              47              434               436
9                              43              434               428
10                             36              430               418
11                             37              413               420
13                             33              422               428
14                             39              412               438
15                             39              422               438
16                             57              466               467
17                             36              448               433
# Writing the Data in the Local File
write.csv(stabda5d_truncated, "stabda5d.csv", row.names = FALSE)

Creating One More Table: Long format

Pretest

library(reshape)
# Demo Data
stabd5d_demo <- select(stabda5d_truncated, 1:5)

# Pretest Data
stabd5d_pretest <- select(stabda5d_truncated,1,6,8,10)

stabda5d_pretest <- melt(stabd5d_pretest, id = c("Std_ID"), measured = c("Test_Standard_Score_Pre","National_Curve_Equivalent_Pre","Growth_Scale_Pre"))

# Changing the Column Names
colnames(stabda5d_pretest) <- c("Std_ID", "Test_Type", "Pretest_Scores")

# Changing the Description on Column Test_Type 
stabda5d_pretest$Test_Type <- factor(stabda5d_pretest$Test_Type, labels = c("Test Standard Score", "National Curve Equivalent Score","Growth Scale Score"))
stabda5d_pretest
       Std_ID                       Test_Type Pretest_Scores
1   Student 1             Test Standard Score             92
2   Student 2             Test Standard Score             90
3   Student 4             Test Standard Score             79
4   Student 5             Test Standard Score             87
5   Student 7             Test Standard Score             91
6   Student 9             Test Standard Score             91
7  Student 10             Test Standard Score             90
8  Student 11             Test Standard Score             82
9  Student 13             Test Standard Score             84
10 Student 14             Test Standard Score             79
11 Student 15             Test Standard Score             84
12 Student 16             Test Standard Score            104
13 Student 17             Test Standard Score             97
14  Student 1 National Curve Equivalent Score             39
15  Student 2 National Curve Equivalent Score             36
16  Student 4 National Curve Equivalent Score             21
17  Student 5 National Curve Equivalent Score             32
18  Student 7 National Curve Equivalent Score             37
19  Student 9 National Curve Equivalent Score             37
20 Student 10 National Curve Equivalent Score             36
21 Student 11 National Curve Equivalent Score             25
22 Student 13 National Curve Equivalent Score             28
23 Student 14 National Curve Equivalent Score             21
24 Student 15 National Curve Equivalent Score             28
25 Student 16 National Curve Equivalent Score             56
26 Student 17 National Curve Equivalent Score             46
27  Student 1              Growth Scale Score            406
28  Student 2              Growth Scale Score            401
29  Student 4              Growth Scale Score            375
30  Student 5              Growth Scale Score            394
31  Student 7              Growth Scale Score            434
32  Student 9              Growth Scale Score            434
33 Student 10              Growth Scale Score            430
34 Student 11              Growth Scale Score            413
35 Student 13              Growth Scale Score            422
36 Student 14              Growth Scale Score            412
37 Student 15              Growth Scale Score            422
38 Student 16              Growth Scale Score            466
39 Student 17              Growth Scale Score            448

Posttest

# Posttest Data
stabd5d_posttest <- select(stabda5d_truncated,1,7,9,11)

stabd5d_posttest <- melt(stabd5d_posttest, id = c("Std_ID"), measured = c("Test_Standard_Score_Post","National_Curve_Equivalent_Post","Growth_Scale_Post"))

# Changing the Column Names
colnames(stabd5d_posttest) <- c("Std_ID", "Test_Type", "Posttest_Scores")

# Changing the Description on Column Test_Type 
stabd5d_posttest$Test_Type <- factor(stabd5d_posttest$Test_Type, labels = c("Test Standard Score", "National Curve Equivalent Score","Growth Scale Score"))

Combining the Data

table_1 <- merge(stabd5d_demo,stabda5d_pretest, by = "Std_ID")
stabd5d_Long <- merge(table_1,stabd5d_posttest, by = c("Std_ID", "Test_Type"))

stabd5d_Long <- select(stabd5d_Long,"Std_ID","Gender","Grade","Attendance","Wordsread", "Test_Type","Pretest_Scores","Posttest_Scores")

stabd5d_Long
       Std_ID Gender        Grade Attendance Wordsread
1   Student 1 Female  Third Grade         16     51858
2   Student 1 Female  Third Grade         16     51858
3   Student 1 Female  Third Grade         16     51858
4  Student 10   Male Fourth Grade         18     21316
5  Student 10   Male Fourth Grade         18     21316
6  Student 10   Male Fourth Grade         18     21316
7  Student 11 Female Fourth Grade         18     19662
8  Student 11 Female Fourth Grade         18     19662
9  Student 11 Female Fourth Grade         18     19662
10 Student 13   Male  Fifth Grade         14     30453
11 Student 13   Male  Fifth Grade         14     30453
12 Student 13   Male  Fifth Grade         14     30453
13 Student 14 Female  Fifth Grade         17     31066
14 Student 14 Female  Fifth Grade         17     31066
15 Student 14 Female  Fifth Grade         17     31066
16 Student 15 Female  Fifth Grade         17     71353
17 Student 15 Female  Fifth Grade         17     71353
18 Student 15 Female  Fifth Grade         17     71353
19 Student 16 Female  Fifth Grade         16     48149
20 Student 16 Female  Fifth Grade         16     48149
21 Student 16 Female  Fifth Grade         16     48149
22 Student 17 Female  Fifth Grade         18     36191
23 Student 17 Female  Fifth Grade         18     36191
24 Student 17 Female  Fifth Grade         18     36191
25  Student 2 Female  Third Grade         18     28575
26  Student 2 Female  Third Grade         18     28575
27  Student 2 Female  Third Grade         18     28575
28  Student 4   Male  Third Grade         17     38867
29  Student 4   Male  Third Grade         17     38867
30  Student 4   Male  Third Grade         17     38867
31  Student 5 Female  Third Grade         14     33160
32  Student 5 Female  Third Grade         14     33160
33  Student 5 Female  Third Grade         14     33160
34  Student 7 Female Fourth Grade         17     16631
35  Student 7 Female Fourth Grade         17     16631
36  Student 7 Female Fourth Grade         17     16631
37  Student 9   Male Fourth Grade         15     19578
38  Student 9   Male Fourth Grade         15     19578
39  Student 9   Male Fourth Grade         15     19578
                         Test_Type Pretest_Scores Posttest_Scores
1               Growth Scale Score            406             387
2  National Curve Equivalent Score             39              28
3              Test Standard Score             92              84
4               Growth Scale Score            430             418
5  National Curve Equivalent Score             36              36
6              Test Standard Score             90              90
7               Growth Scale Score            413             420
8  National Curve Equivalent Score             25              37
9              Test Standard Score             82              91
10              Growth Scale Score            422             428
11 National Curve Equivalent Score             28              33
12             Test Standard Score             84              88
13              Growth Scale Score            412             438
14 National Curve Equivalent Score             21              39
15             Test Standard Score             79              92
16              Growth Scale Score            422             438
17 National Curve Equivalent Score             28              39
18             Test Standard Score             84              92
19              Growth Scale Score            466             467
20 National Curve Equivalent Score             56              57
21             Test Standard Score            104             105
22              Growth Scale Score            448             433
23 National Curve Equivalent Score             46              36
24             Test Standard Score             97              90
25              Growth Scale Score            401             423
26 National Curve Equivalent Score             36              50
27             Test Standard Score             90             100
28              Growth Scale Score            375             372
29 National Curve Equivalent Score             21              19
30             Test Standard Score             79              78
31              Growth Scale Score            394             398
32 National Curve Equivalent Score             32              35
33             Test Standard Score             87              89
34              Growth Scale Score            434             436
35 National Curve Equivalent Score             37              47
36             Test Standard Score             91              98
37              Growth Scale Score            434             428
38 National Curve Equivalent Score             37              43
39             Test Standard Score             91              95
# Writing the Data in the Local File
write.csv(stabd5d_Long, "stabd5d_Long.csv", row.names = FALSE)