library(ggplot2)
# クラス中の40人のテストの点数(点数順)
x <- c(16, 24, 27, 31, 32, 32, 33, 33, 36, 36, 37, 38, 39, 40, 40,
42, 43, 43, 43, 44, 44, 45, 46, 46, 48, 50, 50, 52, 52, 53, 54,
65, 62, 66, 70, 75, 73, 82, 88, 89)
x
p <-
tibble::tibble(x = x) |>
ggplot(aes(x)) +
geom_density() +
xlim(0, 100) +
labs(title = "40名のテスト点数の分布")
p +
geom_vline(xintercept = median(x), color = course_colors[1]) +
geom_vline(xintercept = mean(x), color = course_colors[2]) +
geom_label(aes(mean(x), 0.01),
label = "平均値",
color = course_colors[2],
show.legend = FALSE) +
geom_label(aes(median(x), 0.02),
label = "中央値",
color = course_colors[1],
show.legend = FALSE)