library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
Data <- read_csv("Persentase Rumah Tangga yang Memiliki Akses terhadap Sumber Air Minum Layak Menurut Provinsi, 2025.csv",
skip = 3,
col_names = c("Provinsi", "Persentase")) %>%
filter(!is.na(Provinsi) & Provinsi != "INDONESIA") %>%
mutate(Persentase = as.numeric(Persentase))
## Rows: 39 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Provinsi
## dbl (1): Persentase
##
## ℹ 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.
# BAGIAN 1: ANALISIS STATISTIKA DESKRIPTIF
length(Data$Persentase)
## [1] 38
mean(Data$Persentase)
## [1] 87.60789
median(Data$Persentase)
## [1] 89.935
range(Data$Persentase)
## [1] 32.89 99.98
max(Data$Persentase) - min(Data$Persentase)
## [1] 67.09
max(Data$Persentase)
## [1] 99.98
min(Data$Persentase)
## [1] 32.89
var(Data$Persentase)
## [1] 134.9053
sd(Data$Persentase)
## [1] 11.61487
quantile(Data$Persentase)
## 0% 25% 50% 75% 100%
## 32.8900 83.2925 89.9350 94.8975 99.9800
# BAGIAN 2: VISUALISASI 1 - HISTOGRAM (NASIONAL)
ggplot(Data, aes(x = Persentase)) +
geom_histogram(
binwidth = 10,
boundary = 30,
fill = "pink",
color = "black"
) +
scale_x_continuous(
breaks = seq(30, 100, by = 10),
limits = c(30, 100)
) +
labs(
title = "Persentase Akses Air Minum Layak di Indonesia 2025",
x = "Persentase (%)",
y = "Freq"
) +
theme_classic() +
theme(
axis.text.x = element_text(angle = 0, hjust = 0.5),
plot.title = element_text(hjust = 0.5, face = "bold")
)

# BAGIAN 3: VISUALISASI 2 - BOXPLOT (NASIONAL)
ggplot(Data, aes(x = "", y = Persentase)) +
geom_boxplot(fill = "red") +
labs(
title = "Box Plot Akses Air Minum Layak Indonesia 2025",
x = "",
y = "Persentase (%)"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold")
)

# BAGIAN 4: VISUALISASI KHUSUS PROVINSI KALIMANTAN TIMUR
Rata_Kalimantan <- mean(Data$Persentase[str_starts(Data$Provinsi, "KALIMANTAN")])
Rata_Nasional <- mean(Data$Persentase)
Kaltim_Val <- Data$Persentase[Data$Provinsi == "KALIMANTAN TIMUR"]
Data_Kaltim_Comp <- data.frame(
Kategori = c("Kalimantan Timur", "Rata-Rata Kalimantan", "Rata-Rata Nasional"),
Persentase = c(Kaltim_Val, Rata_Kalimantan, Rata_Nasional)
)
Data_Kaltim_Comp
## Kategori Persentase
## 1 Kalimantan Timur 88.45000
## 2 Rata-Rata Kalimantan 84.64200
## 3 Rata-Rata Nasional 87.60789
ggplot(Data_Kaltim_Comp, aes(x = reorder(Kategori, -Persentase), y = Persentase, fill = Kategori)) +
geom_col(width = 0.5) +
geom_text(aes(label = paste0(round(Persentase, 2), "%")), vjust = -0.5, fontface = "bold") +
scale_y_continuous(limits = c(0, 105)) +
labs(
title = "Persentase Akses Air Minum Layak Kalimantan Timur Tahun 2025",
x = "Kategori",
y = "Persentase (%)"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold"),
legend.position = "none"
)
