Data <- read.table("IPM CONSOl MATERI 2 KOMSTAT.txt", header = T)
length(Data$IPM)
## [1] 38
mean(Data$IPM)
## [1] 72.38842
median(Data$IPM)
## [1] 73.18
range(Data$IPM)
## [1] 53.42 83.08
max(Data$IPM)-min(Data$IPM)
## [1] 29.66
max(Data$IPM)
## [1] 83.08
min(Data$IPM)
## [1] 53.42
var(Data$IPM)
## [1] 26.52484
sd(Data$IPM)
## [1] 5.150227
quantile(Data$IPM)
## 0% 25% 50% 75% 100%
## 53.420 71.080 73.180 74.345 83.080
library(ggplot2)
ggplot(Data,aes(x=IPM))+geom_histogram(
binwidth=5,
boundary=60,
fill="pink",
color="black"
)+
scale_x_continuous(
breaks=seq(60,85,by=5),
limits=c(60,85)
)+
labs(
title="IPM di Indonesia",
x="IPM",
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: Removed 2 rows containing non-finite outside the scale range
## (`stat_bin()`).

ggplot(Data,aes(x="",y=IPM))+
geom_boxplot(fill="red")+
labs(title="Box Plot IPM Indonesia 2024", x="", y="IPM")+
theme_minimal()+
theme(plot.title=element_text(hjust=0.5, face="bold"))

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.5.2
## ✔ lubridate 1.9.4 ✔ tibble 3.3.0
## ✔ purrr 1.1.0 ✔ tidyr 1.3.1
## ✔ readr 2.1.5
## ── 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_Kalimantan <- Data %>%
filter(str_starts(Provinsi, "KALIMANTAN"))
Data_Kalimantan
## Provinsi IPM
## 1 KALIMANTAN_BARAT 70.13
## 2 KALIMANTAN_TENGAH 72.73
## 3 KALIMANTAN_SELATAN 73.03
## 4 KALIMANTAN_TIMUR 78.83
## 5 KALIMANTAN_UTARA 73.02
ggplot(Data_Kalimantan, aes(x = Provinsi, y = IPM, fill = Provinsi)) +
geom_col() +
labs(
title = "IPM Pulau Kalimantan Tahun 2024",
x = "Provinsi",
y = "IPM"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(hjust = 0.5, face = "bold"),
legend.position = "none"
)

# Load library
library(ggplot2)
# Baca data
data = read.table("PRODUK CONSOL MATERI 2 KOMSTAT.txt", header = T, sep = "\t")
data
## Nama_Produk Kategori Penjualan
## 1 Beras Sembako 35
## 2 Minyak_Goreng Sembako 75
## 3 Gula_Pasir Sembako 60
## 4 Mie_Instan Makanan 150
## 5 Biskuit Makanan 85
## 6 Susu_UHT Makanan 70
## 7 The_Celup Makanan 55
## 8 Sabun_Mandi Perawatan 90
## 9 Sampo Perawatan 65
## 10 Pasta_Gigi Perawatan 70
## 11 Sabun_Cuci_ Muka Perawatan 45
# Buat barplot dengan ggplot2
ggplot(data, aes(x = Nama_Produk, y = Penjualan, fill = Kategori)) +
geom_bar(stat = "identity") +
labs(
title = "Jumlah Penjualan Produk Toko MUTIA",
x = "Produk",
y = "Jumlah Penjualan"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(hjust = 0.5, face = "bold")
)# Agregasi data (total penjualan per kategori)

total_penjualan <- aggregate(Penjualan ~ Kategori, data, sum)
total_penjualan
## Kategori Penjualan
## 1 Makanan 360
## 2 Perawatan 270
## 3 Sembako 170
# Buat barplot dengan ggplot2
ggplot(total_penjualan, aes(x = Kategori, y = Penjualan, fill = Kategori)) +
geom_bar(stat = "identity") +
labs(
title = "Jumlah Penjualan per Kategori",
x = "Kategori",
y = "Jumlah Penjualan"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(hjust = 0.5, face = "bold")
)
