Renewable Energy dataset

library(readr)
energy <- read_csv('../../data/IRENA data.csv', skip=1) 
## Rows: 67200 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): Country/area, Technology, Data Type, Grid connection, Electricity s...
## dbl (1): Year
## 
## ℹ 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.

Gapminder dataset

library(gapminder) 
library(dplyr) 
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
data(gapminder) 
gapminder %>% head
## # A tibble: 6 × 6
##   country     continent  year lifeExp      pop gdpPercap
##   <fct>       <fct>     <int>   <dbl>    <int>     <dbl>
## 1 Afghanistan Asia       1952    28.8  8425333      779.
## 2 Afghanistan Asia       1957    30.3  9240934      821.
## 3 Afghanistan Asia       1962    32.0 10267083      853.
## 4 Afghanistan Asia       1967    34.0 11537966      836.
## 5 Afghanistan Asia       1972    36.1 13079460      740.
## 6 Afghanistan Asia       1977    38.4 14880372      786.

Carbon emissions

library(dplyr)
library(readr)


url <- 'https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.csv'

carbon <- read_csv(url) 
## Rows: 50191 Columns: 79
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (2): country, iso_code
## dbl (77): year, population, gdp, cement_co2, cement_co2_per_capita, co2, co2...
## 
## ℹ 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.
carbon %>% head
## # A tibble: 6 × 79
##   country  year iso_code population   gdp cement_co2 cement_co2_per_capita   co2
##   <chr>   <dbl> <chr>         <dbl> <dbl>      <dbl>                 <dbl> <dbl>
## 1 Afghan…  1750 AFG         2802560    NA          0                     0    NA
## 2 Afghan…  1751 AFG              NA    NA          0                    NA    NA
## 3 Afghan…  1752 AFG              NA    NA          0                    NA    NA
## 4 Afghan…  1753 AFG              NA    NA          0                    NA    NA
## 5 Afghan…  1754 AFG              NA    NA          0                    NA    NA
## 6 Afghan…  1755 AFG              NA    NA          0                    NA    NA
## # ℹ 71 more variables: co2_growth_abs <dbl>, co2_growth_prct <dbl>,
## #   co2_including_luc <dbl>, co2_including_luc_growth_abs <dbl>,
## #   co2_including_luc_growth_prct <dbl>, co2_including_luc_per_capita <dbl>,
## #   co2_including_luc_per_gdp <dbl>, co2_including_luc_per_unit_energy <dbl>,
## #   co2_per_capita <dbl>, co2_per_gdp <dbl>, co2_per_unit_energy <dbl>,
## #   coal_co2 <dbl>, coal_co2_per_capita <dbl>, consumption_co2 <dbl>,
## #   consumption_co2_per_capita <dbl>, consumption_co2_per_gdp <dbl>, …

Levelized cost of energy

library(readr)
library(dplyr)
url <- 'https://raw.githubusercontent.com/ericmkeen/sewanee_esus/master/02_energy_sector/levelized-cost-of-energy.csv'
econ <- read_csv(url)
## Rows: 3402 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): country, source
## dbl (2): year, cost
## 
## ℹ 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.
econ %>% head
## # A tibble: 6 × 4
##   country    year source                     cost
##   <chr>     <dbl> <chr>                     <dbl>
## 1 Australia  2010 Bioenergy                NA    
## 2 Australia  2010 Geothermal               NA    
## 3 Australia  2010 Offshore wind            NA    
## 4 Australia  2010 Solar photovoltaic        0.424
## 5 Australia  2010 Concentrated solar power NA    
## 6 Australia  2010 Hydropower               NA

making a plot

library(ggplot2)
ggplot(econ, 
       aes(x=year,
           y= cost,
           color=source)) + 
  geom_point() +
  geom_hline(yintercept=0.05, lty=2) + 
  geom_hline(yintercept=0.18, lty=3) +
  annotate(geom='text',
           x=1990, y=0.1,
           size=5,
           label='Range of fossil\n fuel costs')
## Warning: Removed 2724 rows containing missing values or values outside the scale range
## (`geom_point()`).

library(knitr)
econ %>%
  filter(year == 2020) %>%
  group_by(source) %>%
  summarize(cost = mean(cost, na.rm=TRUE)) %>% kable
source cost
Bioenergy 0.0724731
Concentrated solar power 0.1066530
Geothermal 0.0542640
Hydropower 0.0459659
Offshore wind 0.0862658
Onshore wind 0.0448345
Solar photovoltaic 0.0641493