Exploratory Data Analysis

Data PISA Score 2015

IMPORT DATA

library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.3.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
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
setwd("D:/kulyeah/6. semester 6/Big Data")
data <- read.table("fdata_cleaned.txt", sep = ',',  header = T)
head(data)
##        X         country birthYear gender internationalGrade  talkAboutMaths
## 1 105097     Switzerland      1996   Male                 10       Sometimes
## 2 270652           Italy      1996   Male                 10 Never or rarely
## 3 131414 Czech Republic       1996   Male                  8 Never or rarely
## 4 447976         Sweden       1996   Male                 10                
## 5 243870           Italy      1996 Female                 10       Sometimes
## 6 384162       Portugal       1996 Female                  9                
##   helpFriendsMaths extracurricularActivity participateInCompetitions
## 1        Sometimes                       2                         1
## 2        Sometimes                       1                         3
## 3        Sometimes                       1                         1
## 4                                       NA                        NA
## 5  Never or rarely                       1                         1
## 6                                       NA                        NA
##   studyMoreThan2ExtraHoursADay playChess computerProgramming
## 1                            2         1                   1
## 2                            2         3                   2
## 3                            1         1                   2
## 4                           NA        NA                  NA
## 5                            1         2                   2
## 6                           NA        NA                  NA
##   participateInMathClub Math_InterestsEnjoysReading Math_LookForwardtoLessons
## 1                     1                           2                         3
## 2                     1                           3                         2
## 3                     1                           2                         3
## 4                    NA                          NA                        NA
## 5                     1                           1                         1
## 6                    NA                          NA                        NA
##   Math.EnjoyMaths Math.Interested Motivation_
## 1               4               4           4
## 2               3               3           3
## 3               2               2           3
## 4              NA              NA          NA
## 5               1               1           2
## 6              NA              NA          NA
##   MotivationWorthwhileForCareerChances MotivationImportantForFutureStudy
## 1                                    4                                 3
## 2                                    3                                 3
## 3                                    2                                 3
## 4                                   NA                                NA
## 5                                    1                                 1
## 6                                   NA                                NA
##   MotivationHelpsGetJob ProblemSolvingCanHandleLotofInformation
## 1                     3                                       4
## 2                     4                                       4
## 3                     4                                       3
## 4                    NA                                      NA
## 5                     1                                       1
## 6                    NA                                      NA
##   ProblemSolvingQuicktoUnderstand ProblemSolvingSeekExplanations
## 1                               3                              4
## 2                               3                              2
## 3                               3                              4
## 4                              NA                             NA
## 5                               2                              2
## 6                              NA                             NA
##   ProblemSolvingCanLinkFacts ProblemSolvingLikeSolveComplexProblems MathScore
## 1                          4                                      4  492.1405
## 2                          2                                      5  533.7358
## 3                          3                                      2  506.4730
## 4                         NA                                     NA  520.4938
## 5                          2                                      4  439.6401
## 6                         NA                                     NA  434.1876
##   ReadScore ScienceScore motivation interest behaivior prob_solv_skills
## 1  392.9348     426.2775       3.50     3.25  1.333333              3.8
## 2  506.8110     515.4233       3.25     2.75  2.000000              3.2
## 3  482.6725     532.8609       3.00     2.25  1.166667              3.0
## 4  516.4344     492.1112         NA       NA        NA               NA
## 5  490.0139     454.9981       1.25     1.00  1.333333              2.2
## 6  459.8301     536.1246         NA       NA        NA               NA

Data berjumlah sebanyak 97098 baris / observasi dengan 33 variabel

Visualisasi Data Matematika

skormath <- data %>% filter(!is.na(MathScore)) %>% group_by(country) %>% summarise(meanMath = mean(MathScore)) %>% arrange(desc(meanMath)) %>%  select(country, meanMath)
head(skormath)
## # A tibble: 6 × 2
##   country             meanMath
##   <chr>                  <dbl>
## 1 "China (Shanghai) "     610.
## 2 "Singapore"             567.
## 3 "Hong Kong-China"       561.
## 4 "Chinese Taipei "       555.
## 5 "Republic of Korea"     553.
## 6 "Japan"                 538.
fig1 <- plot_ly(
  x = c(skormath$country),
  y = c(skormath$meanMath),
  name = "Skor Matematika",
  type = "bar"
)

mathgender <- data %>% filter(!is.na(gender) & !is.na(MathScore)) %>% select(gender, MathScore)
boxmath <- plot_ly(mathgender, x= ~gender, y = ~MathScore, color = ~gender, type = "box")

talkmath <- data %>% filter(!is.na(talkAboutMaths)) %>% count(talkAboutMaths)
talkmath <- talkmath[-1,]
piemath <- plot_ly(talkmath, labels = ~talkAboutMaths, values = ~n, type = "pie")

mathchart <- subplot(fig1, boxmath, nrows = 2, margin = 0.07)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
mathchart <- mathchart %>% layout(title = "Skor Matematika PISA Tahun 2015",
                      xaxis = list(zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'),
                        yaxis = list( 
                              zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'))
mathchart
piemath %>% layout(title= "Persentase Siswa yang membicarakan matematika")

Dapat dilihat bahwa negara china mendominasi skor matematika dengan mendapatkan rataan tertinggi. Selain itu, ternyata secara keseluruhan skor matematika laki - laki lebih tinggi dibandingkan wanita

Peserta Tes PISA, ternyata tidak selalu membicarakan matematika. Bahkan yang jarang dan tidak pernah berbincang matematika ada sebanyak >30%

Visualisasi Data Literasi

skorbaca <- data %>% filter(!is.na(ReadScore)) %>% group_by(country) %>% summarise(meanread = mean(ReadScore)) %>% arrange(desc(meanread)) %>%  select(country, meanread)
head(skorbaca)
## # A tibble: 6 × 2
##   country             meanread
##   <chr>                  <dbl>
## 1 "China (Shanghai) "     567.
## 2 "Hong Kong-China"       541.
## 3 "Japan"                 538.
## 4 "Republic of Korea"     537.
## 5 "Singapore"             536.
## 6 "Poland "               524.
fig2 <- plot_ly(
  x = c(skorbaca$country),
  y = c(skorbaca$meanread),
  name = "Skor Baca",
  type = "bar",
  marker = list(color = 'rgb(158,202,225)')
)

readgender <- data %>% select(gender, ReadScore)
boxread <- plot_ly(readgender, x = ~gender, y = ~ReadScore, color = ~gender ,type = "box")

readchart <- subplot(fig2, boxread, nrows = 2, margin = 0.07)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
readchart <- readchart %>% layout(title = "Skor Literasi PISA Tahun 2015",
                      xaxis = list(zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'),
                        yaxis = list( 
                              zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'))
readchart
study <- data %>% filter(!is.na(studyMoreThan2ExtraHoursADay)) %>% count(studyMoreThan2ExtraHoursADay)
piestudy <- plot_ly(study, labels = ~studyMoreThan2ExtraHoursADay, values = ~n, type = "pie")
piestudy %>% layout(title = "Persentase Tingkatan Lama Belajar Tambahan Siswa")

Lagi - lagi negara China memegang skor tertinggi dalam hal membaca. Hal ini berbanding lurus dengan skor matematika yang dijelaskan sebelumnya.

Sedangkan berdasar gender, didapat bahwa secara keseluruhan rata - rata wanita mendapatkan skor baca lebih baik dibandingkan laki - laki.

Ternyata, peserta pisa mayoritas tidak banyak menambah jam belajar mereka. Hal ini wajar karena peserta PIsA bukanlah siswa terbaik setiap negara melainkan rata - rata yang menggambarkan negara tersebut.

Visualisasi Data Science

skorscience <- data %>% filter(!is.na(ScienceScore)) %>% group_by(country) %>% summarise(meanscience = mean(ScienceScore)) %>% arrange(desc(meanscience)) %>%  select(country, meanscience)
head(skorscience)
## # A tibble: 6 × 2
##   country             meanscience
##   <chr>                     <dbl>
## 1 "China (Shanghai) "        579.
## 2 "Hong Kong-China"          554.
## 3 "Japan"                    548.
## 4 "Singapore"                545.
## 5 "Estonia"                  542.
## 6 "Republic of Korea"        538.
fig3 <- plot_ly(
  x = c(skorscience$country),
  y = c(skorscience$meanscience),
  name = "Skor Science",
  type = "bar",
  marker = list(color = 'rgb(58,200,225)')
)

sciencegender <- data %>% select(gender, ScienceScore)
boxscience <- plot_ly(sciencegender, x = ~gender, y = ~ScienceScore, color = ~gender, type = "box" )

sciencechart <- subplot(fig3, boxscience, nrows = 2, margin = 0.07)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
sciencechart <- sciencechart %>% layout(title = "Skor Science PISA Tahun 2015",
                      xaxis = list(zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'),
                        yaxis = list( 
                              zerolinecolor = '#ffff', 
                              zerolinewidth = 1, 
                              gridcolor = 'ffff'))
sciencechart
probsolv <- data %>% filter(!is.na(prob_solv_skills)) %>% select(prob_solv_skills)

histps <- plot_ly(x = ~probsolv$prob_solv_skills, type = "histogram")
histps <- histps %>% layout(title = "Histogram Problem Solving Skills", bargap = 0.1)
histps

Untuk ke-3 kalinya, pada penyelenggaraan PISA tahun 2015, China berhasil mengungguli bidang science. Sama dengan 2 bidang sebelumnya, China mendapatkan skor tertinggi dengan nilai rata - rata 578.9.

Pada sebaran nilai berdasar gender, untuk nilai science baik laki - laki maupun wanita memiliki sebaran nilai yang tidak jauh berbeda. Artinya kemampuan rata - rata science siswa di dunia tidak berbeda antara pria dan wanita.

Sebaran data histogram problem solving menunjukan mayoritas siswa memiliki skor 2 sampai 3.

GABUNGAN DATA

skorbaca <- skorbaca %>% arrange(country)
skormath <- skormath %>% arrange(country)
skorscience <- skorscience %>% arrange(country)

databaru <- data.frame(skorbaca$country, skormath$meanMath, skorbaca$meanread, skorscience$meanscience)

colnames(databaru) <- c("country", "meanmath", "meanread", "meanscience")

skorgrup <- databaru %>% plot_ly()
skorgrup <- skorgrup %>% add_trace(x = ~country, y = ~meanmath, type = 'bar', name = "meanmath", text = databaru$meanmath, textposition = 'auto', marker = list(color = "#22a7f0", line = list(color = 'rgb(8,48,107)', width = 1.5)))
skorgrup <- skorgrup %>% add_trace(x = ~country, y = ~meanread, type = 'bar', name = "meanread", text = databaru$meanread, textposition = 'auto', marker = list(color = "#76c68f", line = list(color = 'rgb(8,48,107)', width = 1.5)))
skorgrup <- skorgrup %>% add_trace(x = ~country, y = ~meanscience, type = 'bar', name = "meanscience" , text = databaru$meanscience, textposition = 'auto', marker = list(color =  "#c9e52f", line = list(color = 'rgb(8,48,107)', width = 1.5)))

skorgrup <- skorgrup %>% layout(title = 'Skor Pisa Dunia 2015',
                                barmode = 'group',
                                xaxis = list(title = ""),
                                yaxis = list(title = ""))

skorgrup

TINGKATAN KELAS PESERTA PISA 2015

# PIE CHART TINGKAT KELAS
dfgrade <- data %>% count(internationalGrade)
dfgrade <- dfgrade[-c(7:8),]
grade <- plot_ly(dfgrade, labels = ~internationalGrade, values = ~n, type = "pie")
grade %>% layout(title = 'Persentase Tingkatan Kelas Peserta PISA 2015')

Dapat dilihat ternyata mayoritas peserta berada di kelas 10 (International Grade)

STUDENT MOTIVATION & INTEREST

# BUBBLE CHART
hub <- data %>% filter(!is.na(motivation) & !is.na(interest)) %>%  rowwise()  %>% mutate(meanscore = mean(c(MathScore, ReadScore, ScienceScore))) %>% select(country,meanscore, motivation, interest)
hub <- hub %>% group_by(country) %>% summarise(meanmot = mean(motivation), meanint = mean(interest))  %>% select(country, meanmot, meanint)

bub <- plot_ly(hub, x = ~meanint, y = ~meanmot, text = ~country, type = 'scatter', mode = 'markers', color = ~country) %>% layout(title = "Student Motivation  & Interest PISA 2015")
bub
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

PEMBERIAN NAMA NEGARA

bub <- plot_ly(hub, x = ~meanint, y = ~meanmot, text = ~country, type = 'scatter', mode = 'markers', color = ~country) %>% add_text(text = ~country, textposition = 'bottom center') %>% layout(title = "Student Motivation  & Interest PISA 2015", showlegend = F)
bub 
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors