pacman::p_load(tidyverse,haven)In-class Exercise 1a: Now You 👀 It!
Loading R packages
In this hands-on exercise, 2 R packages will be used. They are:
The code chunk used as follows:
Filtering PISA data
Note
the code under this section filtered PISA data to include only SG data
the dataset is saved as a rds file called stu_qqq_SG.rds and loaded back as a dataframe.
only stu_qqq_SG.rds will be imported for efficiency purpose for the rest of exercise.
The code chunk below uses read_sas() of haven to import PISA data into R environment.
stu_qqq <- read_sas("data/cy08msp_stu_qqq.sas7bdat")The code chunk below use filter() of dplyr to filter observation in SG only.
stu_qqq_SG <- stu_qqq %>%
filter(CNT == "SGP")The code chunk below use write_rds() to save the data into rds format.
write_rds(stu_qqq_SG,
"data/stu_qqq_SG.rds")Importing filtered PISA data
The code chunk below uses read_rds() to import PISA SG data into R environment.
stu_qqq_SG <- read_rds("data/stu_qqq_SG.rds")