Packages and
dataset
library(haven)
library(ggplot2)
PISA.dat <- read_spss("PISA_tawian2022_trimmed_lab.sav")
Theme setting
common_theme <- theme_classic(base_size = 14) +
theme(
plot.title = element_text(
hjust = 0.5,
face = "bold",
size = 16
),
axis.title = element_text(size = 13),
axis.text = element_text(size = 11),
axis.line = element_line(
color = "black",
linewidth = 0.5
)
)
bar plot for
WORKPAY
p1 <- ggplot(PISA.dat, aes(x = WORKPAY)) +
geom_bar(
fill = "#4C72B0",
color = "black",
linewidth = 0.3,
width = 0.7
) +
scale_x_continuous(breaks = 0:10) +
labs(
title = "bar Plot for WORKPAY",
x = "times for working for pay per day",
y = "Number of Students"
) +
common_theme
p1

bar plot of Gender
p3 <- ggplot(PISA.dat, aes(x = Gender)) +
geom_bar(
fill = "#55A868",
color = "black",
linewidth = 0.3,
width = 0.7
) +
scale_x_continuous(breaks = c(1, 2)) +
labs(
title = "bar Plot for Gender",
x = "Gender",
y = "Number of Students"
) +
common_theme
p3

histogram for
PV1MATH
p4 <- ggplot(PISA.dat, aes(x = PV1MATH)) +
geom_histogram(
binwidth = 20,
fill = "#DD8452",
color = "white",
linewidth = 0.3
) +
labs(
title = "histogram for PV1MATH (binwidth = 20)",
x = "PV1MATH Score",
y = "Frequency"
) +
common_theme
p4

box plot for
PV1MATH
p5 <- ggplot(PISA.dat, aes(y = PV1MATH)) +
geom_boxplot(
fill = "#B7D6EC",
color = "black",
outlier.color = "#C44E52",
outlier.size = 2,
width = 0.3,
linewidth = 0.5
) +
labs(
title = "box Plot for PV1MATH",
x = NULL,
y = "PV1MATH Score"
) +
common_theme +
theme(
axis.text.x = element_blank(),
axis.ticks.x = element_blank()
)
p5
