library(tidyverse)
library(readxl)
library(kableExtra)
library(ggplot2)
veri <- read_xlsx("~/hacettepe/Rders/data/odev3.xlsx")
any(is.na(veri))
## [1] FALSE
sum(is.na(veri))
## [1] 0
Veri setinde eksik veri bulunmamaktadır.
library(gt) library(dplyr)
cinsiyet_df <- veri %>% count(Cinsiyet) %>% mutate(Oran = round(n / sum(n) * 100, 1))
cinsiyet_df %>% gt() %>% tab_header(title = “Cinsiyet Dağılımı”) %>% fmt_number(columns = Oran, decimals = 1) %>% cols_label(Cinsiyet = “Cinsiyet”, n = “Frekans”, Oran = “Oran (%)”) %>% tab_options( table.align = “center”, # Tabloyu ortalar column_labels.font.weight = “bold” # Başlıkları kalın yapar )
library(gt)
cinsiyet_dag <- veri %>%
count(Cinsiyet) %>%
mutate(oran = round(n/sum(n)*100, 1)) #Burda "n" countun çıktısı olduğu için direkt aldık
cinsiyet_dag %>%
gt() %>%
tab_header(title = "Cinsiyet Dagilimi") %>%
cols_label(oran = "ORAN", n = "FREKANS", Cinsiyet = "CINSİYET")
Cinsiyet Dagilimi | ||
CINSİYET | FREKANS | ORAN |
---|---|---|
1 | 257 | 77.6 |
2 | 74 | 22.4 |
ses_dag <- veri %>%
count(SES) %>%
mutate(SES_oran = round(n/sum(n)*100,1))
ses_dag %>%
gt() %>%
tab_header(title = "SES Dagilimi") %>%
cols_label(SES = "SES", SES_oran = "ORAN", n = "FREKANS")
SES Dagilimi | ||
SES | FREKANS | ORAN |
---|---|---|
1 | 18 | 5.4 |
2 | 262 | 79.2 |
3 | 51 | 15.4 |
GRAFIK ILE GOSTERİM
ggplot(cinsiyet_dag, aes(x = factor(Cinsiyet, labels = c("Kadin", "Erkek")),
y = n,
fill = factor(Cinsiyet))) +
geom_bar(stat = "identity", show.legend = FALSE)+
theme_minimal()+
labs(title = "Cinsiyet Dagilimi", x = "Cinsiyet", y = "Frekans")
ggplot(ses_dag, aes(x = factor(SES, labels = c("1", "2", "3")),
y = n,
fill = factor(SES))) +
geom_bar(stat = "identity", show.legend = FALSE)+
theme_minimal()+
labs(title = "SES Dagilimi", x = "SES Duzeyi", y = "Frekans")
veri_2 <- veri %>%
mutate(WV1_duz = 8 - WV1,
WV2_duz = 8 - WV2,
WV3_duz = 8 - WV3,
WV4_duz = 8 - WV4,
WV5_duz = 8 - WV5,
WV6_duz = 8 - WV6,
WV7_duz = 8 - WV7,
WV8_duz = 8 - WV8,
WV9_duz = 8 - WV9
)
boyut_1 <- c("WV1_duz", "WV2_duz", "WV3_duz", "WV4_duz", "WV5_duz", "WV6_duz", "WV7_duz", "WV8_duz", "WV9_duz")
boyut_2 <- c("WV10", "WV11", "WV12", "WV13", "WV14", "WV15", "WV16")
veri_2 <- veri_2 %>% mutate(boyut_1_top= rowSums(select(., all_of(boyut_1)), na.rm = TRUE),
boyut_2_top= rowSums(select(., all_of(boyut_2)), na.rm = TRUE))
ggplot(veri_2, aes(x = boyut_1_top)) +
geom_histogram(fill="pink", color ="black",
linetype = "dashed") +
theme_minimal()
ggplot(veri_2, aes(x = boyut_2_top)) +
geom_histogram(fill="yellow", color ="black",
linetype = "dashed") +
theme_minimal()
boyut2_ort <- mean(veri_2$boyut_2_top, na.rm = TRUE)
boyut2_sd <- sd(veri_2$boyut_2_top, na.rm = TRUE)
ggplot(veri_2, aes(x = boyut_2_top)) +
geom_histogram(fill = "yellow", color = "black") +
geom_vline(xintercept = boyut2_ort, color = "red", linetype = "solid", size = 1) +
annotate("text", x = boyut2_ort, y = 10, label = paste("Ortalama:", round(boyut2_ort, 2)), color = "black") +
geom_vline(xintercept = boyut2_ort + boyut2_sd, color = "blue", linetype = "dashed", size = 1) +
annotate("text", x = boyut2_ort + boyut2_sd, y = 10, label = "+1 SD", color = "black", vjust = -1) +
geom_vline(xintercept = boyut2_ort - boyut2_sd, color = "blue", linetype = "dashed", size = 1) +
annotate("text", x = boyut2_ort - boyut2_sd, y = 10, label = "-1 SD", color = "black", vjust = -1) + theme_minimal() +
labs(title = "Boyut 2 Puan Dagilimi ve Referans Cizgileri", x = "Boyut 2 Puani", y = "Frekans")