library(ggplot2)
library(readr)
student_mat <- read_delim("student-mat.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
## Rows: 395 Columns: 33
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (17): school, sex, address, famsize, Pstatus, Mjob, Fjob, reason, guardi...
## dbl (16): age, Medu, Fedu, traveltime, studytime, failures, famrel, freetime...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
1.Belirli bir sütun seçme:
## # A tibble: 395 × 3
## Mjob Fjob guardian
## <chr> <chr> <chr>
## 1 at_home teacher mother
## 2 at_home other father
## 3 at_home other mother
## 4 health services mother
## 5 other other father
## 6 services other mother
## 7 other other mother
## 8 other teacher mother
## 9 services other mother
## 10 other other mother
## # ℹ 385 more rows
Açıklama: Veri setinde anne ve baba meslekleri ile veli tercihleri seçilmiştir.
2.Belirli bir koşula göre filtreleme yapma:
## # A tibble: 43 × 33
## school sex age address famsize Pstatus Medu Fedu Mjob Fjob reason
## <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
## 1 GP F 18 U GT3 A 4 4 at_home teacher course
## 2 GP F 15 U LE3 T 1 1 at_home other other
## 3 GP F 15 R GT3 T 2 2 at_home other reput…
## 4 GP F 16 U GT3 T 3 4 at_home other course
## 5 GP F 16 U LE3 T 2 2 at_home other course
## 6 GP F 15 R GT3 T 1 1 at_home other home
## 7 GP F 16 U GT3 T 2 2 at_home other home
## 8 GP M 15 R GT3 T 3 4 at_home teacher course
## 9 GP M 17 R GT3 T 3 4 at_home other course
## 10 GP F 16 U LE3 T 1 1 at_home at_home course
## # ℹ 33 more rows
## # ℹ 22 more variables: guardian <chr>, traveltime <dbl>, studytime <dbl>,
## # failures <dbl>, schoolsup <chr>, famsup <chr>, paid <chr>,
## # activities <chr>, nursery <chr>, higher <chr>, internet <chr>,
## # romantic <chr>, famrel <dbl>, freetime <dbl>, goout <dbl>, Dalc <dbl>,
## # Walc <dbl>, health <dbl>, absences <dbl>, G1 <dbl>, G2 <dbl>, G3 <dbl>
Açıklama: Veri setinden annesi çalışmayan ve kreşe gidenler filtrelenmiştir.
3.Yeni bir sütun oluşturma:
## # A tibble: 395 × 34
## school sex age address famsize Pstatus Medu Fedu Mjob Fjob reason
## <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
## 1 GP F 18 U GT3 A 4 4 at_home teach… 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 servi… home
## 5 GP F 16 U GT3 T 3 3 other other home
## 6 GP M 16 U LE3 T 4 3 services other reput…
## 7 GP M 16 U LE3 T 2 2 other other home
## 8 GP F 17 U GT3 A 4 4 other teach… home
## 9 GP M 15 U LE3 A 3 2 services other home
## 10 GP M 15 U GT3 T 3 4 other other home
## # ℹ 385 more rows
## # ℹ 23 more variables: guardian <chr>, traveltime <dbl>, studytime <dbl>,
## # failures <dbl>, schoolsup <chr>, famsup <chr>, paid <chr>,
## # activities <chr>, nursery <chr>, higher <chr>, internet <chr>,
## # romantic <chr>, famrel <dbl>, freetime <dbl>, goout <dbl>, Dalc <dbl>,
## # Walc <dbl>, health <dbl>, absences <dbl>, G1 <dbl>, G2 <dbl>, G3 <dbl>,
## # high_note <lgl>
Açıklama: Final notu 15’ten büyük öğrencileri görmek için “mutate” fonksiyonu ile yeni bir sütun oluşturulmuştur.
1.Boxplot Grafiği: Anne mesleki durumunun öğrencilerin final notlarına etkisi
library(dplyr)
student_mat %>%
mutate(anne_durumu = ifelse(Mjob == "at_home","Calismiyor","Calisiyor")) %>%
ggplot(aes(x = anne_durumu, y = G3)) +
geom_boxplot() +
theme_sub_legend() +
labs (title = "Annenin Mesleki Durumu ile Final Notu Arasindaki İliski", x ="Anne Mesleki Durumu", y = "Final Notu")
Yorum: Grafik oluşturmak için “anne_durumu” isminde yeni bir sütun eklenmiş ve bu sütunda at_home verisi ile diğer tüm meslekler “Çalışıyor/Çalışmıyor” şeklinde kategorize edilmiştir.Ardından annenin çalışıp çalışmamasına göre öğrencilerin final notları araştırılmış ancak annenin çalışıp çalışmamasının öğrencinin final notuna belirgin bir etkisinin olmadığı görülmüştür.
2.Scatter Plot Grafiği: Aile kalitesinin final notlarına etkisi
library(ggplot2)
ggplot(student_mat, aes(x = famrel, y = G3)) +
geom_point(color = "orchid", size = 3) +
theme_classic() +
labs(
title = "Aile İlişkisi Kalitesi ile Final Notu Arasındaki İlişki",
x = "Aile İlişkisi (1 = Cok Kotu, 5 = Cok İyi)",
y = "Final Notu"
)
Yorum: Grafik incelendiğinde, aile ilişkisi kalitesi (famrel) ile öğrencilerin final notları (G3) arasında zayıf bir ilişki olduğu görülmektedir. Tüm kategorilerde geniş bir dağılım gözlendiğinden, aile ilişkisi tek başına akademik başarıyı güçlü biçimde açıklamamaktadır.