data1 <- read.csv("C:\\Users\\yuuen\\OneDrive\\Documents\\Kuliah\\IPB\\Semester 4\\Visdat\\Kelompok\\co2-per-capita-vs-renewable-electricity\\co2-per-capita-vs-renewable-electricity.csv")
head(data1)
## Entity Code Year Per.capita.emissions
## 1 ASEAN (Ember) 2000 NA
## 2 ASEAN (Ember) 2001 NA
## 3 ASEAN (Ember) 2002 NA
## 4 ASEAN (Ember) 2003 NA
## 5 ASEAN (Ember) 2004 NA
## 6 ASEAN (Ember) 2005 NA
## Share.of.electricity.from.renewables World.region.according.to.OWID
## 1 19.34709
## 2 19.06632
## 3 17.66430
## 4 16.67030
## 5 15.69780
## 6 15.15065
str(data1)
## 'data.frame': 27646 obs. of 6 variables:
## $ Entity : chr "ASEAN (Ember)" "ASEAN (Ember)" "ASEAN (Ember)" "ASEAN (Ember)" ...
## $ Code : chr "" "" "" "" ...
## $ Year : int 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 ...
## $ Per.capita.emissions : num NA NA NA NA NA NA NA NA NA NA ...
## $ Share.of.electricity.from.renewables: num 19.3 19.1 17.7 16.7 15.7 ...
## $ World.region.according.to.OWID : chr "" "" "" "" ...
data2 <- read.csv("C:\\Users\\yuuen\\OneDrive\\Documents\\Kuliah\\IPB\\Semester 4\\Visdat\\Kelompok\\co-emissions-per-capita (1)\\co-emissions-per-capita.csv")
str(data2)
## 'data.frame': 26509 obs. of 4 variables:
## $ Entity : chr "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
## $ Code : chr "AFG" "AFG" "AFG" "AFG" ...
## $ Year : int 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 ...
## $ CO..emissions.per.capita: num 0.00199 0.01084 0.01163 0.01147 0.01312 ...
data3 <- read.csv("C:\\Users\\yuuen\\OneDrive\\Documents\\Kuliah\\IPB\\Semester 4\\Visdat\\Kelompok\\ghg-emissions-by-sector\\ghg-emissions-by-sector.csv")
str(data3)
## 'data.frame': 6969 obs. of 14 variables:
## $ Entity : chr "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
## $ Code : chr "AFG" "AFG" "AFG" "AFG" ...
## $ Year : int 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ...
## $ Agriculture : num 8410000 8750000 8780000 8860000 8940000 ...
## $ Land.use.change.and.forestry : num 0 0 0 0 0 0 0 0 0 0 ...
## $ Waste : int 1020000 1030000 1150000 1340000 1480000 1570000 1640000 1700000 1770000 1840000 ...
## $ Buildings : num 150000 160000 180000 190000 200000 200000 210000 200000 200000 210000 ...
## $ Industry : num 150000 140000 120000 120000 80000 70000 60000 60000 60000 60000 ...
## $ Manufacturing.and.construction: num 570000 530000 390000 380000 360000 340000 320000 300000 280000 250000 ...
## $ Transport : num 970000 930000 740000 740000 730000 730000 700000 670000 670000 490000 ...
## $ Electricity.and.heat : num 320000 300000 200000 200000 190000 180000 170000 160000 160000 160000 ...
## $ Fugitive.emissions : num 2069999 390000 230000 230000 230000 ...
## $ Other.fuel.combustion : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Aviation.and.shipping : int 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 ...
data4 <- read.csv("C:\\Users\\yuuen\\OneDrive\\Documents\\Kuliah\\IPB\\Semester 4\\Visdat\\Kelompok\\renewable-share-energy\\renewable-share-energy.csv")
str(data4)
## 'data.frame': 6379 obs. of 4 variables:
## $ Entity : chr "Africa" "Africa" "Africa" "Africa" ...
## $ Code : chr "" "" "" "" ...
## $ Year : int 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 ...
## $ Renewables: num 5.42 5.77 5.96 6.61 7.51 ...
data5 <- read.csv("C:\\Users\\yuuen\\OneDrive\\Documents\\Kuliah\\IPB\\Semester 4\\Visdat\\Kelompok\\share-elec-by-source (1)\\share-elec-by-source.csv")
str(data5)
## 'data.frame': 7662 obs. of 12 variables:
## $ Entity : chr "ASEAN (Ember)" "ASEAN (Ember)" "ASEAN (Ember)" "ASEAN (Ember)" ...
## $ Code : chr "" "" "" "" ...
## $ Year : int 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 ...
## $ Coal : num 20.1 21.3 21.6 22.3 23.2 ...
## $ Gas : num 43.4 47 48.2 49.4 49.2 ...
## $ Hydropower : num 13.3 13.4 12.3 11.6 10.7 ...
## $ Solar : num 0 0 0 0 0 ...
## $ Wind : num 0 0 0 0 0 ...
## $ Oil : num 17.2 12.6 12.5 11.6 12 ...
## $ Nuclear : num 0 0 0 0 0 0 0 0 0 0 ...
## $ Other.renewables: num 4.47 4.05 3.83 3.43 3.34 ...
## $ Bioenergy : num 1.55 1.6 1.53 1.63 1.69 ...
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
data_indonesia <- data2 %>%
filter(Entity == "Indonesia", Code == "IDN")
colnames(data2)
## [1] "Entity" "Code"
## [3] "Year" "CO..emissions.per.capita"
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.1 ✔ readr 2.1.5
## ✔ ggplot2 3.5.2 ✔ stringr 1.5.1
## ✔ lubridate 1.9.4 ✔ tibble 3.3.0
## ✔ purrr 1.1.0 ✔ tidyr 1.3.1
## ── 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
co2_filtered <- data2 %>%
filter(Entity %in% c("Indonesia", "World")) %>%
select(Entity, Year, CO..emissions.per.capita)
ggplot(co2_filtered, aes(x = Year, y = CO..emissions.per.capita, color = Entity)) +
geom_line(size = 1) +
labs(
title = "Tren Emisi CO2 per Kapita",
y = "CO2 per Kapita (ton)",
x = "Year",
color = "Negara"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

indo_2023 <- data3 %>%
filter(Entity == "Indonesia", Year == 2023)
indo_long <- indo_2023 %>%
pivot_longer(
cols = Agriculture:Aviation.and.shipping,
names_to = "Sector",
values_to = "Emissions"
)
indo_long <- indo_long %>%
mutate(
Percentage = Emissions / sum(Emissions) * 100
)
ggplot(indo_long, aes(x = "", y = Emissions, fill = Sector)) +
geom_bar(stat = "identity", width = 1) +
coord_polar("y") +
geom_text(aes(label = paste0(round(Percentage,1), "%")),
position = position_stack(vjust = 0.5),
size = 3) +
theme_void() +
labs(
title = "Proporsi Emisi Gas Rumah Kaca Indonesia (2023)"
)

indo_long %>%
arrange(desc(Emissions)) %>%
ggplot(aes(x = reorder(Sector, Emissions), y = Emissions)) +
geom_col() +
coord_flip() +
labs(
title = "Emisi Gas Rumah Kaca per Sektor di Indonesia (2023)",
x = "",
y = "Emisi"
) +
theme_minimal()

indo_reg <- data1 %>%
filter(Entity == "Indonesia") %>%
select(Year, Per.capita.emissions, Share.of.electricity.from.renewables)
ggplot(indo_reg, aes(x = Per.capita.emissions, y = Share.of.electricity.from.renewables)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
theme_minimal() +
labs(
title = "Hubungan CO2 per Kapita dan Renewable Energy",
x = "CO2 per Kapita",
y = "Renewable Electricity (%)"
)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 96 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 96 rows containing missing values or values outside the scale range
## (`geom_point()`).

model <- lm(Share.of.electricity.from.renewables ~ Per.capita.emissions, data = indo_reg)
summary(model)
##
## Call:
## lm(formula = Share.of.electricity.from.renewables ~ Per.capita.emissions,
## data = indo_reg)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.8512 -1.7641 -0.3198 1.6383 6.8240
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 22.5824 1.2445 18.146 < 2e-16 ***
## Per.capita.emissions -2.6392 0.7354 -3.589 0.000936 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.749 on 38 degrees of freedom
## (96 observations deleted due to missingness)
## Multiple R-squared: 0.2531, Adjusted R-squared: 0.2335
## F-statistic: 12.88 on 1 and 38 DF, p-value: 0.0009363
sumberenergi <- data5 %>%
filter(Entity == "Indonesia")
indo_energy <- sumberenergi %>%
pivot_longer(
cols = Coal:Bioenergy,
names_to = "Source",
values_to = "Share"
)
ggplot(indo_energy, aes(x = Year, y = Share, color = Source)) +
geom_line(size = 1) +
labs(
title = "Tren Sumber Energi Indonesia (sampai 2024)",
x = "Year",
y = "Share (%)",
color = "Energy Source"
) +
theme_minimal()
## Warning: Removed 30 rows containing missing values or values outside the scale range
## (`geom_line()`).

latest_year <- max(sumberenergi$Year)
snapshot <- sumberenergi %>%
filter(Year == latest_year) %>%
pivot_longer(
cols = Coal:Bioenergy,
names_to = "Source",
values_to = "Share"
)
ggplot(snapshot, aes(x = reorder(Source, Share), y = Share)) +
geom_col() +
coord_flip() +
labs(
title = paste("Energy Mix Indonesia", latest_year),
y = "Share (%)",
x = ""
) +
theme_minimal()
