# Load library
library(ggplot2)
library(dplyr)
## 
## 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(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ lubridate 1.9.5     ✔ tibble    3.3.1
## ✔ purrr     1.2.2     ✔ tidyr     1.3.2
## ✔ readr     2.2.0
## ── 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
# Baca data
Data <- read.table(file.choose(), header = T, sep = "\t")
Data
##                Provinsi  Tahunan
## 1                  ACEH   8462.8
## 2        SUMATERA_UTARA  28959.7
## 3        SUMATERA_BARAT  14757.3
## 4                  RIAU  54625.8
## 5                 JAMBI  16021.3
## 6      SUMATERA_SELATAN  47193.7
## 7              BENGKULU   2760.9
## 8               LAMPUNG  12743.7
## 9  KEP._BANGKA_BELITUNG   8137.7
## 10            KEP._RIAU  21240.4
## 11          DKI_JAKARTA 175277.0
## 12           JAWA_BARAT 149840.8
## 13          JAWA_TENGAH  37639.1
## 14        DI_YOGYAKARTA   6770.7
## 15           JAWA_TIMUR 101759.0
## 16               BANTEN  73199.8
## 17                 BALI  17211.8
## 18  NUSA_TENGGARA_BARAT  49252.6
## 19  NUSA_TENGGARA_TIMUR   3705.2
## 20     KALIMANTAN_BARAT  17069.2
## 21    KALIMANTAN_TENGAH  16537.0
## 22   KALIMANTAN_SELATAN  23574.2
## 23     KALIMANTAN_TIMUR  70926.6
## 24     KALIMANTAN_UTARA  11558.2
## 25       SULAWESI_UTARA   6106.3
## 26      SULAWESI_TENGAH   7992.5
## 27     SULAWESI_SELATAN  11528.6
## 28    SULAWESI_TENGGARA   6705.8
## 29            GORONTALO   4947.5
## 30       SULAWESI_BARAT   1514.1
## 31               MALUKU   1088.7
## 32         MALUKU_UTARA   7814.3
## 33          PAPUA_BARAT    602.8
## 34     PAPUA_BARAT_DAYA   2662.7
## 35                PAPUA   1096.6
## 36        PAPUA_SELATAN   8626.7
## 37         PAPUA_TENGAH    389.3
## 38     PAPUA_PEGUNUNGAN     13.7
# 1. Histogram
ggplot(Data, aes(x = Tahunan)) +
  geom_histogram(
    binwidth = 25000,
    boundary = 0,
    fill = "pink",
    color = "black"
  ) +
  scale_x_continuous(
    breaks = seq(0, 200000, by = 25000),
    labels = function(x) format(x, big.mark = ".", scientific = FALSE)
  ) +
  labs(
    title = "Realisasi Investasi PMDN Indonesia 2025",
    x = "Realisasi Investasi (Milyar Rupiah)",
    y = "Freq"
  ) +
  theme_classic() +
  theme(
    axis.text.x = element_text(angle = 0, hjust = 0.5),
    plot.title = element_text(hjust = 0.5, face = "bold")
  )
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' and 'decimal.mark' are both '.', which could be confusing

# 2. Boxplot
ggplot(Data, aes(x = "", y = Tahunan)) +
  geom_boxplot(fill = "red") +
  labs(
    title = "Box Plot Realisasi Investasi PMDN 2025",
    x = "",
    y = "Milyar Rupiah"
  ) +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, face = "bold"))

# 3. Barplot Pulau Kalimantan
Data_Kalimantan <- Data %>%
  filter(str_starts(Provinsi, "KALIMANTAN"))
Data_Kalimantan
##             Provinsi Tahunan
## 1   KALIMANTAN_BARAT 17069.2
## 2  KALIMANTAN_TENGAH 16537.0
## 3 KALIMANTAN_SELATAN 23574.2
## 4   KALIMANTAN_TIMUR 70926.6
## 5   KALIMANTAN_UTARA 11558.2
ggplot(Data_Kalimantan, aes(x = Provinsi, y = Tahunan, fill = Provinsi)) +
  geom_col() +
  labs(
    title = "Realisasi Investasi PMDN Pulau Kalimantan Tahun 2025",
    x = "Provinsi",
    y = "Milyar Rupiah"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1),
    plot.title = element_text(hjust = 0.5, face = "bold"),
    legend.position = "none"
  )

library(ggplot2)
ggplot(Data, aes(x = Tahunan)) +
  geom_histogram(binwidth = 25000, boundary = 0,
                 fill = "pink", color = "black") +
  scale_x_continuous(breaks = seq(0, 200000, by = 25000)) +
  labs(title = "Realisasi Investasi PMDN Indonesia 2025",
       x = "Realisasi Investasi (Milyar Rupiah)", y = "Freq") +
  theme_classic() +
  theme(plot.title = element_text(hjust = 0.5, face = "bold"))

library(ggplot2)

ggplot(Data, aes(x = reorder(Provinsi, -Tahunan), y = Tahunan, fill = Provinsi)) +
  geom_col() +
  scale_y_continuous(
    labels = function(x) format(x, big.mark = ".", scientific = FALSE)
  ) +
  labs(
    title = "Realisasi Investasi PMDN Seluruh Provinsi di Indonesia Tahun 2025",
    x = "Provinsi",
    y = "Milyar Rupiah"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5, size = 8),
    plot.title = element_text(hjust = 0.5, face = "bold"),
    legend.position = "none"
  )
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' and 'decimal.mark' are both '.', which could be confusing