This is me rn

THE LIBRARY

library(tidyverse)

THE DATA

data <- read.csv("student_depression_dataset.csv", sep = ",")
data_depressed = as.tibble(data)

THE GRAPH

HEATMAP

data_depressed %>%
  count(Have.you.ever.had.suicidal.thoughts.., Family.History.of.Mental.Illness) %>%
  ggplot(aes(x = Have.you.ever.had.suicidal.thoughts.., y = Family.History.of.Mental.Illness, fill = n)) +
  geom_tile() +
  geom_text(aes(label = n), color = "white") +
  scale_fill_gradient(low = "#E0BBE4", high = "#5D3A9B") +  # dari ungu muda ke ungu tua
  labs(
    fill = "Jumlah",
    title = "Heatmap Kombinasi Suicidal Thoughts dan Riwayat Keluarga",
    x = "Suicidal Thoughts",
    y = "Riwayat Keluarga"
  ) +
  theme_minimal()

THE BAR CHART

ggplot(data_depressed, aes(x = Have.you.ever.had.suicidal.thoughts.., fill = Family.History.of.Mental.Illness)) +
  geom_bar(position = "dodge") +
  labs(
    y = "Jumlah",
    x = "Suicidal Thoughts",
    title = "Perbandingan Suicidal Thoughts Berdasarkan Riwayat Penyakit Mental Keluarga",
    fill = "Riwayat Keluarga\nDengan Penyakit Mental"
  ) +
  scale_fill_manual(values = c("Yes" = "#C71585", "No" = "#9370DB")) +  # Pink tua & ungu muda
  theme_minimal()

Kombinasi Risiko Mental: Siapa yang Paling Rentan Terkena Depresi?

data_summary <- data_depressed %>%
  mutate(
    Depression_num = ifelse(Depression %in% c("Yes", "Ya, Depresi", 1), 1, 0),
    kombinasi = interaction(Have.you.ever.had.suicidal.thoughts.., Family.History.of.Mental.Illness),
    kombinasi = recode(kombinasi,
      "No.No" = "Tidak Suicidal & Tidak Ada Riwayat Keluarga",
      "Yes.No" = "Suicidal & Tidak Ada Riwayat Keluarga",
      "No.Yes" = "Tidak Suicidal & Ada Riwayat Keluarga",
      "Yes.Yes" = "Suicidal & Ada Riwayat Keluarga"
    )
  ) %>%
  group_by(kombinasi) %>%
  summarise(prop_depresi = mean(Depression_num, na.rm = TRUE))

# Visualisasi
ggplot(data_summary, aes(x = kombinasi, y = prop_depresi, fill = kombinasi)) +
  geom_col() +
  geom_text(aes(label = scales::percent(prop_depresi, accuracy = 0.1)), vjust = -0.5) +
  scale_fill_manual(values = c(
    "Tidak Suicidal & Tidak Ada Riwayat Keluarga" = "#DDA0DD",
    "Suicidal & Tidak Ada Riwayat Keluarga" = "#DA70D6",
    "Tidak Suicidal & Ada Riwayat Keluarga" = "#FF69B4",
    "Suicidal & Ada Riwayat Keluarga" = "#C71585"
  )) +
  labs(
    title = "Proporsi Depresi per Kombinasi Suicidal Thoughts dan Riwayat Keluarga",
    x = "Kombinasi Risiko",
    y = "Proporsi Depresi",
    fill = "Kombinasi Faktor"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 15, hjust = 1))