Project Part 1

Preparing “per capita CO2 emissions” for plotting

  1. I downloaded per capita CO2 emission data from Our World in Data. Climate change is one of the biggest issues that my generation has to come up with solutions for quick. Rising levels of CO2 in the atmosphere are causing catastrophic changes that could ultimately lead the extinction of mankind if we don’t act as fast as possible. This data will be used to analyze ten countries and the amount they produced (per capita) from 1950 - 2020.

  2. This is the link to the data.

  3. The following code chunk loads the package I will use to read in and prepare the data for analysis.

  1. Read the data in.
annual_co_emissions_by_country <- read_csv(here::here("_posts/2022-05-10-project-part-1/co2.csv"))
  1. Use glimpse to see the names and types of columns.
glimpse(annual_co_emissions_by_country)
Rows: 24,032
Columns: 4
$ Entity                              <chr> "Afghanistan", "Afghanis~
$ Code                                <chr> "AFG", "AFG", "AFG", "AF~
$ Year                                <dbl> 1949, 1950, 1951, 1952, ~
$ `Annual CO2 emissions (per capita)` <dbl> 0.0019, 0.0109, 0.0117, ~
  1. Use output from glimpse to prepare the data for analysis.
countries  <- c("China",
               "United States",
               "India",
               "Russia",
               "Japan",
               "Iran",
               "Germany",
               "South Korea",
               "Saudi Arabia",
               "Indonesia")

country_co2  <- annual_co_emissions_by_country  %>% 
  rename(Country = 1, CO2emissions = 4)  %>% 
  filter(Year >= 1950, Country %in%  countries)  %>% 
  select(Country, Year, CO2emissions)

country_co2
# A tibble: 708 x 3
   Country  Year CO2emissions
   <chr>   <dbl>        <dbl>
 1 China    1950        0.142
 2 China    1951        0.179
 3 China    1952        0.220
 4 China    1953        0.226
 5 China    1954        0.267
 6 China    1955        0.311
 7 China    1956        0.347
 8 China    1957        0.406
 9 China    1958        0.819
10 China    1959        1.11 
# ... with 698 more rows
  1. Check that the total for 2020 equals the total in the graph
country_co2 %>% filter(Year==2020) %>%
  summarise(total_emm=sum(CO2emissions))
# A tibble: 1 x 1
  total_emm
      <dbl>
1      90.7
  1. Add a picture.
CO2 emissions per capita
  1. Write the data to file in the project directory.
write_csv(country_co2, file="country_co2.csv")