Lembaga : Universitas Islam Negeri Maulana Malik Ibrahim Malang
library(readxl)
## Warning: package 'readxl' was built under R version 4.1.2
jawa <- read_excel(path = "Jawa Bali.xlsx")
jawa
## # A tibble: 110 x 5
## Pulau Provinsi Tahun Inflow Outflow
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Jawa Jawa 2011 123917. 83511.
## 2 Jawa Jawa 2012 160482. 111363.
## 3 Jawa Jawa 2013 134998. 98969.
## 4 Jawa Jawa 2014 217303. 147069.
## 5 Jawa Jawa 2015 230141. 171568.
## 6 Jawa Jawa 2016 261607. 190568.
## 7 Jawa Jawa 2017 277609. 228905.
## 8 Jawa Jawa 2018 306911. 253125.
## 9 Jawa Jawa 2019 324624. 271957.
## 10 Jawa Jawa 2020 259444. 251363.
## # ... with 100 more rows
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.1.2
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
jawa %>%
ggplot(mapping = aes(x = Tahun, y = Inflow)) +
geom_point() +
facet_wrap(~ Provinsi)

library(ggplot2)
library(dplyr)
jawa %>%
ggplot(mapping = aes(x = Tahun, y = Outflow)) +
geom_line()+
geom_point() +
facet_wrap(~ Provinsi)

jatim <-
jawa %>%
ggplot(aes(Tahun, Inflow)) +
geom_line() +
geom_point() +
geom_vline(xintercept = 2013, color = "blue")
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.6 v purrr 0.3.4
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'tibble' was built under R version 4.1.2
## Warning: package 'tidyr' was built under R version 4.1.2
## Warning: package 'readr' was built under R version 4.1.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
tigajawa <-
jawa %>%
filter(
Provinsi %in% c("Bali", "Bali Nusa" ,"Banten", "Jawa Tengah")
) %>%
filter(Tahun >= 2011, Tahun <= 2021)
tigajawa %>%
mutate(Provinsi = fct_reorder2(Provinsi, Tahun, Inflow)) %>%
ggplot(aes(Tahun, Inflow, color = Provinsi)) +
geom_vline(xintercept = 2016, color = "blue") +
geom_line() +
geom_point() +
theme(legend.justification = "top")

tigajawa %>%
ggplot(aes(Tahun, Inflow, color = Provinsi)) +
geom_vline(xintercept = 2016, color = "blue") +
geom_line() +
geom_point() +
geom_text(
aes(label = Provinsi),
data = tigajawa %>% filter(Tahun == 2019),
color = "black",
hjust = 0,
size = 3,
nudge_x = 0.5
) +
guides(color = "none") +
coord_cartesian(xlim = c(2011, 2021))

jawa %>%
mutate(Provinsi = fct_reorder(Provinsi, Inflow)) %>%
ggplot(aes(Provinsi, Inflow)) +
geom_boxplot() +
geom_hline(aes(yintercept = median(Inflow, na.rm = TRUE)), color = "red")

jawa %>%
mutate(Provinsi = fct_reorder(Provinsi, Inflow)) %>%
ggplot(aes(Provinsi, Inflow)) +
geom_hline(aes(yintercept = median(Inflow, na.rm = TRUE)), color = "red") +
geom_boxplot()+
theme(axis.text.x = element_text(angle = -45))

library(tidyverse)
jawa %>%
ggplot(aes(Inflow)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
