CO2 emission data
When environment is at stake, insights from data count double. While rejustify has been supporting access to environmental data through some of the economic databases, more recently we took an active step and included more direct resources in our AI engine:
- Global, Regional, and National Fossil-Fuel CO2 Emissions prepared by the Carbon Dioxide Information Analysis Center (CDIAC),
- Energy and Emission data as published in the BP Statistical Review of World Energy 2020 release.
The tables are tagged CDIAC-GLOBAL, CDIAC-REGION, CDIAC-COUNTRY and BP-ENERGY, depending on the level of geographical aggregation, and they are supported by all AI functionality offered by rejustify. Let's quickly jump into an example how to access them in your projects.
1. Package installation and setup
Firstly, make sure you have the most recent version of the API, available at github, and setup up you access rights.
install.packages("remotes") #just in case
remotes::install_github("rejustify/r-package")
library(rejustify)
setCurl()
register(token = "YOUR_TOKEN", email = "YOUR_EMAIL")
2. Design your data canvas
Secondly, design your data structure. In the example below, we will rejustify annual data on CO2 emissions between 2020 and 2020 in three large economies: Germany, China and USA. To make ploting easier, we will design the canvas in a specific shape such that the emission columns will be marked by country and indicator dimensions (check table structure).
df <- data.frame(year = seq(2000, 2020),
`Germany,Per capita` = NA,
`China,Per capita` = NA,
`United States,Per capita` = NA, check.names = F )
st <- analyze(df, learn = TRUE)
In case the 'per capita' phrase was identified as a measure of unit, which is correct across several other default data sets, to facilitate the matching between 'per capita' dimension and the indicator dimension in CDIAC-COUNTRY we need to standardize the dimensions. We suggest to switch the classification unit to general, the same as in CDIAC-COUNTRY. If you allow the algorithm to learn, you will do it only once - the next time the rejustify engine will recognize it automatically.
st <- adjust(st, id = 3, items = list("class" = "general", "feature" = NA))
st <- adjust(st, id = 5, items = list("class" = "general", "feature" = NA))
st <- adjust(st, id = 7, items = list("class" = "general", "feature" = NA))
3. Rejustify
Thirdly, rejustify.
rdf <- fill(df, st, learn = TRUE)
Original data set
year Germany,Per capita China,Per capita United States,Per capita
2000 NA NA NA
2001 NA NA NA
2002 NA NA NA
2003 NA NA NA
2004 NA NA NA
2005 NA NA NA
2006 NA NA NA
2007 NA NA NA
2008 NA NA NA
2009 NA NA NA
2010 NA NA NA
2011 NA NA NA
2012 NA NA NA
2013 NA NA NA
2014 NA NA NA
2015 NA NA NA
2016 NA NA NA
2017 NA NA NA
2018 NA NA NA
2019 NA NA NA
2020 NA NA NA
Rejustified data set
year Germany,Per capita China,Per capita United States,Per capita
2000 2.75 0.73 5.42
2001 2.83 0.74 5.27
2002 2.74 0.82 5.26
2003 2.72 0.96 5.24
2004 2.7 1.1 5.26
2005 2.63 1.23 5.25
2006 2.7 1.35 5.12
2007 2.55 1.44 5.13
2008 2.55 1.53 4.93
2009 2.45 1.64 4.61
2010 2.57 1.78 4.69
2011 2.48 1.97 4.56
2012 2.51 2.02 4.38
2013 2.56 2.05 4.38
2014 2.43 2.05 4.43
2015 NA NA NA
2016 NA NA NA
2017 NA NA NA
2018 NA NA NA
2019 NA NA NA
2020 NA NA NA
As explained by CDIAC, the units are thousand metric tons of carbon per capita. Let's quickly visualize the results.
matplot(rdf$data$year, rdf$data[,2:4], xlab="Year", ylab="CO2 Emission", type = "l", col=1:3, lty=1)
legend("topright", legend = colnames(rdf$data[,2:4]), col=1:3, lty=1)
More functionality of the API is described in our R package documentation. The full list of our resources, including data providers and tables, can be found in our repository browser.