# Load the necessary library
library(ggplot2)
# Load data from the CSV file
GlobalCO2Emissions <- read.csv("GlobalCO2Emissions.csv")
# Select the last seven years
lastseven <- tail(GlobalCO2Emissions, 7)
# Visualise the data using ggplot2 as a modified pie chart
ggplot(lastseven, aes(x = "", y = `Emissions`, fill = factor(Year))) +
geom_bar(stat = "identity", width = 1, color = "#000000") +
coord_polar(theta = "y") +
geom_text(data = lastseven, aes(label = sprintf("%.2f", `Emissions`)),
position = position_stack(vjust = 0.5), size = 4, fontface = "bold", color = "#000000") +
labs(title = "Global CO₂ Emissions: Emissions (GtCO₂) vs Year.",
subtitle = "2023: 40.9 gigatons of carbon dioxide is equivalent to 40,900,000,000 metric tons.",
x = NULL,
y = NULL) +
scale_fill_manual(values = c("#FFCC66", "#FFD700", "#FFCC00", "#FF9900", "#FF6600", "#FF3300", "#FF0000")) +
theme_minimal() +
theme(panel.background = element_rect(fill = "#CCCCCC"),
panel.grid = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank())
