data <- read.csv("C:/Users/USER/OneDrive/文档/medsos/media sosial.csv",
  sep = ";",
  dec = ",",
  header = TRUE,
  fill = TRUE,
  check.names = TRUE,
  stringsAsFactors = FALSE
)

head(data)
##   ID_Pengguna Usia Jenis_Kelamin Waktu_Layar_Harian.jam. Kualitas_Tidur.1.10.
## 1        U001   44     Laki-laki                     3.1                    7
## 2        U002   30       Lainnya                     5.1                    7
## 3        U003   23       Lainnya                     7.4                    6
## 4        U004   36     Perempuan                     5.7                    7
## 5        U005   34     Perempuan                     7.0                    4
## 6        U006   38     Laki-laki                     6.6                    5
##   Tingkat_Stres.1.10. Hari_Tanpa_Media_Sosial Frekuensi_Olahraga.per_minggu.
## 1                   6                       2                              5
## 2                   8                       5                              3
## 3                   7                       1                              3
## 4                   8                       1                              1
## 5                   7                       5                              1
## 6                   7                       4                              3
##   Platform_Media_Sosial Indeks_Kebahagiaan.1.10.
## 1              Facebook                       10
## 2              LinkedIn                       10
## 3               YouTube                        6
## 4                TikTok                        8
## 5           X (Twitter)                        8
## 6              LinkedIn                        8

Including Plots

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.2
data %>%
group_by(Platform_Media_Sosial) %>%
summarise(Rata_Stres = mean(Tingkat_Stres.1.10., na.rm = TRUE)) %>%
arrange(desc(Rata_Stres)) %>%
ggplot(aes(x = Platform_Media_Sosial, y = Rata_Stres)) +
geom_col(fill = "steelblue") +
labs(
title = "Rata-rata Tingkat Stres Berdasarkan Platform Media Sosial",
x = "Platform Media Sosial",
y = "Rata-rata Tingkat Stres"
) +
theme_minimal()

data %>%
  ggplot(aes(x = Waktu_Layar_Harian.jam., y = Tingkat_Stres.1.10.)) +
  geom_point(alpha = 0.6, color = "darkred") +
  geom_smooth(method = "lm", se = FALSE, color = "black") +
  labs(
    title = "Hubungan Waktu Layar Harian dan Tingkat Stres",
    x = "Waktu Layar Harian (jam)",
    y = "Tingkat Stres"
  ) +
  theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

data %>%
  ggplot(aes(x = Jenis_Kelamin, y = Tingkat_Stres.1.10., fill = Jenis_Kelamin)) +
  geom_boxplot() +
  labs(
    title = "Distribusi Tingkat Stres Berdasarkan Jenis Kelamin",
    x = "Jenis Kelamin",
    y = "Tingkat Stres"
  ) +
  theme_minimal() +
  theme(legend.position = "none")

data %>%
  ggplot(aes(x = Tingkat_Stres.1.10., y = Indeks_Kebahagiaan.1.10.)) +
  geom_point(alpha = 0.6, color = "steelblue") +
  labs(
    title = "Hubungan Tingkat Stres dan Indeks Kebahagiaan",
    x = "Tingkat Stres",
    y = "Indeks Kebahagiaan"
  ) +
  theme_minimal()

data %>%
  count(Platform_Media_Sosial) %>%
  ggplot(aes(x = "", y = n, fill = Platform_Media_Sosial)) +
  geom_col(width = 1) +
  coord_polar("y") +
  labs(
    title = "Persentase Penggunaan Platform Media Sosial",
    fill = "Platform"
  ) +
  theme_void()