ISSS608 Visual Analytics & Applications Coursework
by Wilson Tan
  • Hands-on Exercises
    • Week 1: Hands-on Exercise
    • Week 2: Hands-on Exercise
    • Week 3: Hands-on Exercise
    • Week 4: Hands-on Exercise
  • In-class Exercises
    • Week 1: In-class Exercise
    • Week 2: In-class Exercise
    • Week 3: In-class Exercise
    • Week 4: In-class Exercise
    • Week 5: In-class Exercise
    • Week 6: In-class Exercise
    • Week 7: In-class Exercise
  • Take-home Exercises
    • Take-home Exercise 01
    • Take-home Exercise 02
    • Take-home Exercise 03

Week 4: In-class Exercise

Load packages and dataset

pacman::p_load(rstatix, gt, patchwork, tidyverse, webshot2, png)
exam_data <- read_csv("data/data_04/Exam_data.csv", show_col_types = FALSE)

Quantile-Quantile (Q-Q) Plot

Q-Q plots are used to check for normality of data. The points should fit close to the straight line if the variable in question is indeed normally distributed.

In this case, we are checking if ‘English’ scores are normally distributed:

  • Plot
  • Code

ggplot(exam_data,
       aes(sample = ENGLISH)) +
  stat_qq() +
  stat_qq_line()
  • Plot
  • Code

qq <- ggplot(exam_data,
             aes(sample = ENGLISH)) +
  stat_qq() +
  stat_qq_line()

sw_t <- exam_data %>% shapiro_test(ENGLISH) %>% gt()

tmp <- tempfile(fileext = ".png")
gtsave(sw_t, tmp)
table_png <- png::readPNG(tmp, native = TRUE)

qq + table_png