::p_load(tidyverse, haven) pacman
In-class Exercise 1
Loading R Packages
In this hands-on exercise, two R packages will be used. They are:
The code chunk used is as follows:
Importing PISA data
The code chunk below uses read_sas() of haven to import PISA data into R environment.
<- read_sas("data/cy08msp_stu_qqq.sas7bdat") stu_qqq
<- stu_qqq %>%
stu_qqq_SG filter(CNT =="SGP")
write_rds(stu_qqq_SG,
"Data/stu_qqq_SG.rds")
<- read_rds("Data/stu_qqq_SG.rds") stu_qqq_SG
head(stu_qqq_SG,10)
# A tibble: 10 × 1,279
CNT CNTRYID CNTSCHID CNTSTUID CYC NatCen STRATUM SUBNATIO REGION OECD
<chr> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl>
1 SGP 702 70200052 70200001 08MS 070200 SGP01 7020000 70200 0
2 SGP 702 70200134 70200002 08MS 070200 SGP01 7020000 70200 0
3 SGP 702 70200112 70200003 08MS 070200 SGP01 7020000 70200 0
4 SGP 702 70200004 70200004 08MS 070200 SGP01 7020000 70200 0
5 SGP 702 70200152 70200005 08MS 070200 SGP01 7020000 70200 0
6 SGP 702 70200043 70200006 08MS 070200 SGP01 7020000 70200 0
7 SGP 702 70200049 70200007 08MS 070200 SGP01 7020000 70200 0
8 SGP 702 70200107 70200008 08MS 070200 SGP01 7020000 70200 0
9 SGP 702 70200012 70200009 08MS 070200 SGP01 7020000 70200 0
10 SGP 702 70200061 70200010 08MS 070200 SGP01 7020000 70200 0
# ℹ 1,269 more variables: ADMINMODE <dbl>, LANGTEST_QQQ <dbl>,
# LANGTEST_COG <dbl>, LANGTEST_PAQ <dbl>, Option_CT <dbl>, Option_FL <dbl>,
# Option_ICTQ <dbl>, Option_WBQ <dbl>, Option_PQ <dbl>, Option_TQ <dbl>,
# Option_UH <dbl>, BOOKID <dbl>, ST001D01T <dbl>, ST003D02T <dbl>,
# ST003D03T <dbl>, ST004D01T <dbl>, ST250Q01JA <dbl>, ST250Q02JA <dbl>,
# ST250Q03JA <dbl>, ST250Q04JA <dbl>, ST250Q05JA <dbl>, ST250D06JA <chr>,
# ST250D07JA <chr>, ST251Q01JA <dbl>, ST251Q02JA <dbl>, ST251Q03JA <dbl>, …
tail(stu_qqq_SG,10)
# A tibble: 10 × 1,279
CNT CNTRYID CNTSCHID CNTSTUID CYC NatCen STRATUM SUBNATIO REGION OECD
<chr> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl>
1 SGP 702 70200005 70207333 08MS 070200 SGP01 7020000 70200 0
2 SGP 702 70200095 70207334 08MS 070200 SGP01 7020000 70200 0
3 SGP 702 70200009 70207336 08MS 070200 SGP01 7020000 70200 0
4 SGP 702 70200122 70207337 08MS 070200 SGP01 7020000 70200 0
5 SGP 702 70200117 70207338 08MS 070200 SGP01 7020000 70200 0
6 SGP 702 70200110 70207341 08MS 070200 SGP01 7020000 70200 0
7 SGP 702 70200045 70207342 08MS 070200 SGP01 7020000 70200 0
8 SGP 702 70200014 70207343 08MS 070200 SGP01 7020000 70200 0
9 SGP 702 70200109 70207344 08MS 070200 SGP01 7020000 70200 0
10 SGP 702 70200154 70207345 08MS 070200 SGP01 7020000 70200 0
# ℹ 1,269 more variables: ADMINMODE <dbl>, LANGTEST_QQQ <dbl>,
# LANGTEST_COG <dbl>, LANGTEST_PAQ <dbl>, Option_CT <dbl>, Option_FL <dbl>,
# Option_ICTQ <dbl>, Option_WBQ <dbl>, Option_PQ <dbl>, Option_TQ <dbl>,
# Option_UH <dbl>, BOOKID <dbl>, ST001D01T <dbl>, ST003D02T <dbl>,
# ST003D03T <dbl>, ST004D01T <dbl>, ST250Q01JA <dbl>, ST250Q02JA <dbl>,
# ST250Q03JA <dbl>, ST250Q04JA <dbl>, ST250Q05JA <dbl>, ST250D06JA <chr>,
# ST250D07JA <chr>, ST251Q01JA <dbl>, ST251Q02JA <dbl>, ST251Q03JA <dbl>, …