title: “perbaikan_uts” author: “joe” date: “2026-10-14” output: html_document —
student_data <- read.csv("student_data.csv")
head(student_data)
## school sex age address famsize Pstatus Medu Fedu Mjob Fjob reason
## 1 GP F 18 U GT3 A 4 4 at_home teacher course
## 2 GP F 17 U GT3 T 1 1 at_home other course
## 3 GP F 15 U LE3 T 1 1 at_home other other
## 4 GP F 15 U GT3 T 4 2 health services home
## 5 GP F 16 U GT3 T 3 3 other other home
## 6 GP M 16 U LE3 T 4 3 services other reputation
## guardian traveltime studytime failures schoolsup famsup paid activities
## 1 mother 2 2 0 yes no no no
## 2 father 1 2 0 no yes no no
## 3 mother 1 2 3 yes no yes no
## 4 mother 1 3 0 no yes yes yes
## 5 father 1 2 0 no yes yes no
## 6 mother 1 2 0 no yes yes yes
## nursery higher internet romantic famrel freetime goout Dalc Walc health
## 1 yes yes no no 4 3 4 1 1 3
## 2 no yes yes no 5 3 3 1 1 3
## 3 yes yes yes no 4 3 2 2 3 3
## 4 yes yes yes yes 3 2 2 1 1 5
## 5 yes yes no no 4 3 2 1 2 5
## 6 yes yes yes no 5 4 2 1 2 5
## absences G1 G2 G3
## 1 6 5 6 6
## 2 4 5 5 6
## 3 10 7 8 10
## 4 2 15 14 15
## 5 4 6 10 10
## 6 10 15 15 15
hasil_summary <- summary(student_data$G3)
# ANALISIS STATISTIK DESKRIPTIF
### Perhitungan modus untuk mengetahui nilai akhir (G3) yang paling sering diperoleh oleh siswa:
#Modus
tabel_g3 <- table(student_data$G3)
modus_g3 <- names(tabel_g3)[tabel_g3 == max(tabel_g3)]
cat("Modus dari G3 adalah:", modus_g3)
## Modus dari G3 adalah: 10
# PENGELOMPOKAN DATA
### Tabel di bawah ini menampilkan rata-rata nilai akhir (G3) siswa yang dikelompokkan berdasarkan durasi waktu belajar (studytime):
tabel_ringkasan <- aggregate(G3 ~ studytime, data = student_data, FUN = mean)
print(tabel_ringkasan)
## studytime G3
## 1 1 10.04762
## 2 2 10.17172
## 3 3 11.40000
## 4 4 11.25926
# VISUALISASI DATA
### Berikut adalah grafik histogram untuk melihat sebaran frekuensi nilai akhir siswa (G3):
hist(student_data$G3,
main = "Histogram Nilai Akhir Siswa (G3)",
xlab = "Nilai G3",
ylab = "Frekuensi",
col = "skyblue",
border = "pink"
)