I use the wbstats package to first obtain data on global CO2 emissions per capita in metric tons. I extract the data using world bank API and map the emissions per capita for different countries.
The map below shows that per capita emissions is highest in USA, Canada, Australia and Saudi Arabia, while the emissions are lowest in Sub-Saharan Africa, the Indian subcontinent and South America.
library(wbstats)
library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(viridis)
library(dplyr)
library(sf)
# Get data from indicators
world_map <- rnaturalearth::ne_countries(scale = 50, returnclass = "sf")
co2emission <- wb(country = "countries_only",
indicator = "EN.ATM.CO2E.PC",
mrv = 1)
co2_pc <- left_join(world_map, co2emission, by = c("iso_a2" = "iso2c"))
# Plot world map of CO2 emissions per capita
g <- ggplot(co2_pc) +
geom_sf(aes(fill = value)) +
scale_fill_viridis("value") +
ggtitle("CO2 emissions (metric tons per capita)") +
theme_bw()
g
To get a complete picture, I also extract data on total CO2 emissions (in kt) for each country. This is shown in the map below. The highest CO2 emissions are from China followed by USA followed by India.
co2_tot <- wb(country = "countries_only",
indicator = "EN.ATM.CO2E.KT",
mrv = 1)
co2_kt <- left_join(world_map, co2_tot, by = c("iso_a2" = "iso2c"))
g2 <- ggplot(co2_kt) +
geom_sf(aes(fill = value)) +
scale_fill_viridis("value") +
ggtitle("CO2 emissions (kt)") +
theme_bw()
g2
I use the gtrendsR package to get trends on google searches for Christmas characters in the US. I start my analysis by generating trends for the most popular Christmas character “Santa Claus”. As I suspected there is a large spike in searches for Santa Claus around December each year when it’s Christmas time.
library(gtrendsR)
library(reshape2)
christmas_data1 <- gtrends(c("Santa Claus"), gprop = "web", time = "all", geo = c("US")) [[1]]
g2<-ggplot(christmas_data1, aes(x=date, y=hits)) +
geom_line(color = "red", size = 0.5) + ggtitle("Searches for Santa Claus in the U.S 2004-2022")+
theme(plot.title = element_text(size = 11, face = "bold")) +
theme( plot.title = element_text(hjust = 0.5)) +
ylab("Searches") + xlab("date") +
theme(axis.title = element_text(size = 10))+ theme_classic()
g2
I now compare the popularity of Santa Claus with other familiar christmas characters namely - The Grinch, Ebenezer Scrooge (for whom I only use the search term “Scrooge”) and Rudolph. It seems Ebenezer Scrooge is the least popular Christmas character (no “Humbug” there) followed by Rudolph. It is also interesting to note that The Grinch did steal Christmas in 2018 and 2021 beating Santa Claus by a large margin. This could however be attributed to the 2018 animated movie “The Grinch” which is the highest grossing Christmas film of all time.
christmas_data2 <- gtrends(c("Santa Claus","The Grinch","Scrooge","Rudolph"), gprop = "web", time = "2012-01-01 2022-03-21", geo = c("US")) [[1]]
g3<-ggplot(christmas_data2, aes(x=date, y=hits, color=keyword)) +
geom_line() + ggtitle("Searches for different Christmas characters 2012-2022")+
theme(plot.title = element_text(size = 11, face = "bold")) +
theme( plot.title = element_text(hjust = 0.5)) +
ylab("Searches") + xlab("date") +
theme(axis.title = element_text(size = 8))+ theme_classic()
g3