Loading the Libraries
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.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)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
library(dplyr)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(readr)
dive <- read_csv("dive.csv")
## Rows: 1904 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Country_Name, Country_Code, Clean_Fuel, Rural, Total, Urban, Energy...
## dbl (5): Time, Renewable_output, Renewable_share, Renewable_consumption, Tot...
##
## ℹ 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.
tail(dive)
## # A tibble: 6 × 14
## Country_Name Country_Code Time Clean_Fuel Rural Total Urban Energy_intensity
## <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 Zimbabwe ZWE 2010 30.46 11.62… 36.0… 85.2… 20.71308
## 2 Zimbabwe ZWE 2011 30.27 13.3 36.9 83.2 19.71977119
## 3 Zimbabwe ZWE 2012 30.02 12.98… 36.7… 85.3… 18.43724649
## 4 Zimbabwe ZWE 2013 29.88 13.66… 37.0… 85.3… 18.15296658
## 5 Zimbabwe ZWE 2014 29.63 9.8 32.3 83.4 15.74958139
## 6 Zimbabwe ZWE 2015 29.36 9.7 33.7 81.2 15.80389705
## # ℹ 6 more variables: Renewable_output <dbl>, Renewable_share <dbl>,
## # Renewable_consumption <dbl>, Renewable_total_share <chr>,
## # Total_electricity_output <chr>, Total_consumption <dbl>
###Description ## Here it is seen that there are numerous columns present in the data frame which might create some kind of confusion. we are targeting three columns which were Energy intensity, Renewable consumption and Clean fuel.
##Clean Fuel is defined as the total amount of fuel utilised from clean and natural resources,and how much proportion of households utilise clean fuel for the purpose of cooking and pther activities. ##Energy Intensity means energy consumed percapita during a particular GDP.
##From the Dive dataset, here are three columns (or values) that are unclear until you, go through the documentation: ###Description The “Description” contains text which tells us the terms related to energy, including details about Consumption, Usage, and availability. Without the descriptin it would become challenging enough to go through the columns and get to know about the details further.
unsure_df <- subset(dive, select = c(Country_Code, Clean_Fuel))
unsure_df_20 <- head(unsure_df, 20)
unsure_df_20
## # A tibble: 20 × 2
## Country_Code Clean_Fuel
## <chr> <chr>
## 1 AFG 15.99
## 2 AFG 17.44
## 3 AFG 18.84
## 4 AFG 20.68
## 5 AFG 22.33
## 6 AFG 24.08
## 7 AFG 26.17
## 8 AFG 27.99
## 9 AFG 30.1
## 10 ALB 58.14
## 11 ALB 60.75
## 12 ALB 63.24
## 13 ALB 65.23
## 14 ALB 67.81
## 15 ALB 69.96
## 16 ALB 71.78
## 17 ALB 73.98
## 18 ALB 75.37
## 19 DZA 91.56
## 20 DZA 92.06
# Create a bar plot
plot <- ggplot(unsure_df_20, aes(x = Country_Code, y = Clean_Fuel)) +
geom_bar(stat = "identity", fill = "magenta") +
# Add annotations
annotate("text", x = 5, y = 150, label = "Unsure Context",
color = "green", size = 10) +
labs(x = "Country", y = "Clean Fuel",
title = "Number of Countries with Clean Fuel") +
theme(axis.text.x = element_text(angle = 120, hjust = 1)) +
theme(axis.text.y = element_text(size = 12))
print(plot)