library(tidyverse)
library(stevemisc)
library(knitr)
library(haven)
library(summarytools)
library(outliers)
library(ggplot2)
library(plotly)
library(ggpmisc)
library(psych)
library(sur)
library(moments)
library(corrplot)
library(olsrr)
library(dplyr)
library(kableExtra)
library(readxl)
library(naniar)
library(tidyr)
library(outliers)16 maddelik bir olcek 331 universite ogrencisine uygulanmis.
331 ogrenciye ait veriler odev3.xlsx dosyasinda yer almaktadir.
Olcek 2 faktorden olusmaktadir.
## [1] FALSE
##
## 1 2 3
## 1 13 206 38
## 2 5 56 13
freq(data$Cinsiyet, report.nas = F) %>%
kable(format='markdown',
caption="Frekans Tablosu", digits = 3) %>%
kable_styling(full_width = T, font_size = 14, bootstrap_options = "striped") %>%
row_spec(0, background = "white", color = "black")| Freq | % Valid | % Valid Cum. | % Total | % Total Cum. | |
|---|---|---|---|---|---|
| 1 | 257 | 77.644 | 77.644 | 77.644 | 77.644 |
| 2 | 74 | 22.356 | 100.000 | 22.356 | 100.000 |
| <NA> | 0 | NA | NA | 0.000 | 100.000 |
| Total | 331 | 100.000 | 100.000 | 100.000 | 100.000 |
freq(data$SES, report.nas = F) %>%
kable(format='markdown',
caption="Frekans Tablosu", digits = 3) %>%
kable_styling(full_width = T, font_size = 14, bootstrap_options = "striped") %>%
row_spec(0, background = "white", color = "black")| Freq | % Valid | % Valid Cum. | % Total | % Total Cum. | |
|---|---|---|---|---|---|
| 1 | 18 | 5.438 | 5.438 | 5.438 | 5.438 |
| 2 | 262 | 79.154 | 84.592 | 79.154 | 84.592 |
| 3 | 51 | 15.408 | 100.000 | 15.408 | 100.000 |
| <NA> | 0 | NA | NA | 0.000 | 100.000 |
| Total | 331 | 100.000 | 100.000 | 100.000 | 100.000 |
cinsiyet_ses_df <- as.data.frame.matrix(cinsiyet_ses_tablosu)
cinsiyet_ses_df <- cbind("Cinsiyet" = rownames(cinsiyet_ses_df), cinsiyet_ses_df)
kable(cinsiyet_ses_df, format = "html", caption = "Cinsiyet ve SES Degiskenlerinin Dagilimi") %>%
kable_styling(full_width = TRUE,
bootstrap_options = c("striped", "hover", "responsive")) %>%
column_spec(1, width = "25%", bold = TRUE) %>%
column_spec(2:(ncol(cinsiyet_ses_df)), width = "15%") %>%
add_header_above(c(" " = 1, "SES Kategorileri" = ncol(cinsiyet_ses_df) - 1)) %>%
scroll_box(width = "100%", height = "500px")| Cinsiyet | 1 | 2 | 3 |
|---|---|---|---|
| 1 | 13 | 206 | 38 |
| 2 | 5 | 56 | 13 |
ggplot(data, aes(x = factor(Cinsiyet), fill = factor(SES))) +
geom_bar(position = "dodge") +
scale_fill_brewer(palette = "Set2") +
theme_minimal() +
labs(title = "Cinsiyet ve SES Kategorilerinin Dagilimi",
x = "Cinsiyet",
y = "Frekans",
fill = "SES") +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.text = element_text(size = 12),
axis.title = element_text(size = 13))cinsiyet_ses_frekans <- data %>%
group_by(Cinsiyet, SES) %>%
summarise(Frekans = n(), .groups = "drop")
plot_ly(
data = cinsiyet_ses_frekans,
x = ~Cinsiyet,
y = ~Frekans,
color = ~factor(SES),
type = "bar",
text = ~paste("Cinsiyet:", Cinsiyet, "<br>SES:", SES, "<br>Frekans:", Frekans),
hoverinfo = "text"
) %>%
layout(
title = "Cinsiyet ve SES Kategorilerinin İnteraktif Dagilimi",
xaxis = list(title = "Cinsiyet"),
yaxis = list(title = "Frekans"),
barmode = "group",
plot_bgcolor = "white"
)ggplot2::ggplot(data, aes(x = factor(Cinsiyet))) +
geom_bar(fill = "purple", color = "black", na.rm = T) +
theme_minimal() +
labs(title = "Cinsiyet Histogrami",
x = "Cinsiyet Degerleri",
y = "Frekans") +
theme(plot.title = element_text(hjust = 0.5, size = 14))Cinsiyet_frekans <- data %>%
group_by(Cinsiyet) %>%
summarise(Frekans = n())
plot_ly(
data = Cinsiyet_frekans,
x = ~Cinsiyet,
y = ~Frekans,
type = "bar",
marker = list(color = "purple", line = list(color = "black", width = 1.2))
) %>%
layout(
title = "Cinsiyet Degiskeninin Kategorik Dagilimi",
xaxis = list(title = "Cinsiyet Kategorileri", tickmode = "array", tickvals = c(1, 2, 3), showgrid = FALSE),
yaxis = list(title = "Frekans", showgrid = F),
plot_bgcolor = "white"
)ggplot2::ggplot(data, aes(x = SES)) +
geom_histogram(bins = 3, fill = "pink", color = "black") +
scale_x_continuous(breaks = unique(data$SES)) +
theme_minimal() +
labs(title = "SES Histogrami",
x = "SES Kategorileri",
y = "Frekans") +
theme(plot.title = element_text(hjust = 0.5, size = 14))ses_frekans <- data %>%
group_by(SES) %>%
summarise(Frekans = n())
plot_ly(
data = ses_frekans,
x = ~SES,
y = ~Frekans,
type = "bar",
marker = list(color = "pink", line = list(color = "black", width = 1.2))
) %>%
layout(
title = "SES Degiskeninin Kategorik Dagilimi",
xaxis = list(title = "SES Kategorileri", tickmode = "array", tickvals = c(1, 2, 3), showgrid = FALSE),
yaxis = list(title = "Frekans", showgrid = FALSE),
plot_bgcolor = "white"
)data2 <- data %>%
dplyr::mutate(
WV1 = 8 - WV1,
WV2 = 8 - WV2,
WV3 = 8 - WV3,
WV4 = 8 - WV4,
WV5 = 8 - WV5,
WV6 = 8 - WV6,
WV7 = 8 - WV7,
WV8 = 8 - WV8,
WV9 = 8 - WV9
)
head(data2)boyut1_maddeleri <- c("WV1", "WV2", "WV3", "WV4", "WV5", "WV6", "WV7", "WV8", "WV9")
boyut2_maddeleri <- c("WV10", "WV11", "WV12", "WV13", "WV14", "WV15", "WV16")
data2 <- data2 %>%
mutate(
Boyut1_Toplam_Puan = rowSums(select(., all_of(boyut1_maddeleri)), na.rm = T),
Boyut2_Toplam_Puan = rowSums(select(., all_of(boyut2_maddeleri)), na.rm = T)
)
head(data2)ggplot(data2, aes(x = Boyut1_Toplam_Puan)) +
geom_histogram(bins = 20, fill = "blue", color = "black", alpha = 0.7) +
theme_minimal() +
labs(title = "Boyut1 Toplam Puan Histogram Dagilimi",
x = "Boyut1 Toplam Puan",
y = "Frekans") +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))ggplot(data2, aes(x = Boyut2_Toplam_Puan)) +
geom_histogram(bins = 20, fill = "red", color = "black", alpha = 0.7) +
theme_minimal() +
labs(title = "Boyut2 Toplam Puan Histogram Dagilimi",
x = "Boyut2 Toplam Puan",
y = "Frekans") +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))data_long <- data2 %>%
pivot_longer(cols = c(Boyut1_Toplam_Puan, Boyut2_Toplam_Puan),
names_to = "Olcek", values_to = "Puan")
ggplot2::ggplot(data_long, aes(x = Puan, fill = Olcek)) +
geom_histogram(alpha = 0.5, position = "identity", bins = 20, color = "black") +
scale_fill_manual(values = c("blue", "red")) +
theme_minimal() +
labs(title = "Boyut1 ve Boyut2 Toplam Puan Dagilimi",
x = "Toplam Puan",
y = "Frekans",
fill = "Alt Olcek") +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))data_long <- data2 %>%
pivot_longer(cols = c(Boyut1_Toplam_Puan, Boyut2_Toplam_Puan),
names_to = "Olcek", values_to = "Puan")
plot_ly(data_long, x = ~Puan, color = ~Olcek, type = "histogram",
opacity = 0.6, nbinsx = 20) %>%
layout(
title = "Boyut1 ve Boyut2 Toplam Puan Dagilimi",
xaxis = list(title = "Toplam Puan"),
yaxis = list(title = "Frekans"),
barmode = "overlay",
legend = list(title = list(text = "Alt Ölçek"))
)boyut2_ortalama <- mean(data2$Boyut2_Toplam_Puan, na.rm = T) # MEAN = Ortalama
boyut2_sd <- sd(data2$Boyut2_Toplam_Puan, na.rm = T) # SD = Standart Sapma
ortalama_cizgi <- boyut2_ortalama # Ortalama degeri (33.03) ile elde edilmis cizgi
ust_sapma_cizgi <- boyut2_ortalama + boyut2_sd # Ortalamanin 1 standart sapma USTU icin 'UST sapma cizgisi'
alt_sapma_cizgi <- boyut2_ortalama - boyut2_sd # Ortalamanin 1 standart sapma ALTI icin 'ALT sapma cizgisi'
plot_ly(data2, x = ~Boyut2_Toplam_Puan, type = "histogram",
opacity = 0.6, nbinsx = 20, marker = list(color = "#00008B")) %>%
layout(
title = "Boyut2 Toplam Puan Dagilimi",
xaxis = list(title = "Boyut2 Toplam Puan"),
yaxis = list(title = "Frekans"),
plot_bgcolor = "white",
shapes = list(
list(type = "line", x0 = ortalama_cizgi, x1 = ortalama_cizgi,
y0 = 0, y1 = 1, xref = "x", yref = "paper",
line = list(color = "red", width = 2, dash = "dash")),
list(type = "line", x0 = ust_sapma_cizgi, x1 = ust_sapma_cizgi,
y0 = 0, y1 = 1, xref = "x", yref = "paper",
line = list(color = "green", width = 2, dash = "dot")),
list(type = "line", x0 = alt_sapma_cizgi, x1 = alt_sapma_cizgi,
y0 = 0, y1 = 1, xref = "x", yref = "paper",
line = list(color = "orange", width = 2, dash = "dot"))
),
annotations = list(
list(x = ortalama_cizgi, y = 1, xref = "x", yref = "paper",
text = paste("Ortalama:", round(boyut2_ortalama, 2)),
showarrow = F, font = list(size = 12, color = "red")),
list(x = ust_sapma_cizgi, y = 1, xref = "x", yref = "paper",
text = paste("Ortalama +1 SD:", round(ust_sapma_cizgi, 2)),
showarrow = F, font = list(size = 12, color = "green")),
list(x = alt_sapma_cizgi, y = 1, xref = "x", yref = "paper",
text = paste("Ortalama -1 SD:", round(alt_sapma_cizgi, 2)),
showarrow = F, font = list(size = 12, color = "orange"))
))ggplot(data2, aes(y = Boyut1_Toplam_Puan)) +
geom_boxplot(fill = "blue", color = "black", outlier.color = "red", outlier.shape = 16) +
theme_minimal() +
labs(title = "Boyut1 Toplam Puan Boxplot",
y = "Boyut1 Toplam Puan")boxplot_boyut1 <- plot_ly(data2, y = ~Boyut1_Toplam_Puan, type = "box",
marker = list(color = "red"),
boxpoints = "all",
jitter = 0.3,
pointpos = -1.8,
line = list(color = "black")) %>%
layout(title = "Boyut1 Toplam Puan - Interaktif Boxplot",
yaxis = list(title = "Boyut1 Toplam Puan"),
plot_bgcolor = "white")
boxplot_boyut1ggplot(data2, aes(y = Boyut2_Toplam_Puan)) +
geom_boxplot(fill = "red", color = "black", outlier.color = "blue", outlier.shape = 16) +
theme_minimal() +
labs(title = "Boyut2 Toplam Puan Boxplot",
y = "Boyut2 Toplam Puan")boxplot_boyut2 <- plot_ly(data2, y = ~Boyut2_Toplam_Puan, type = "box",
marker = list(color = "blue"),
boxpoints = "all",
jitter = 0.3,
pointpos = -1.8,
line = list(color = "black")) %>%
layout(title = "Boyut2 Toplam Puan - Interaktif Boxplot",
yaxis = list(title = "Boyut2 Toplam Puan"),
plot_bgcolor = "white")
boxplot_boyut2## [1] 19 19 19 19 18 16 9 18 18
## [1] 21 22 36 37 64 73 273 315 330