library(plotly)
library(tidyverse)

Topic Background

Because I am a big environmentalist, I chose the topic of deforestation. To do this, I chose to plot the change in forest cover (in percentage) for each individual continent from 1990-2020.

Data Overview

The data I used for this visual was originally published by the UN Food and Agriculture Organization (FAO).

Original published form: https://fra-data.fao.org/WO/assessment/fra2020

Where I obtained the data: https://ourworldindata.org/grapher/forest-area-as-share-of-land-area?tab=chart&time=earliest..latest&country=England~Scotland~FRA~USA

forest_data <- readr::read_csv('forest-area-as-share-of-land-area.csv')
summary(forest_data)
nrow(forest_data)
#forest_data
glimpse(forest_data)
forest_data %>%
  group_by(Entity)
forest_data %>%
  ungroup

Wrangling

Although the data is quite wrangled already when downloaded, and is formatted in a suitable way to recreate the original visual, I believe it would be beneficial for others using and interacting with this dataset to be able to discern between the different kinds of entities included, as there are countries, regions, and continents all included without any way to tell each apart or filter accordingly. I intend to create another column for this purpose.

wrangled_forest <- forest_data %>%
  mutate(land_type = as.factor(ifelse(Entity == 'World', 'World',
                            ifelse(!is.na(Code), 'Country', 
                            ifelse(Entity %in% c('Africa' , 'Asia' , 'Central America' , 'Europe' , 'Northern America',  'Oceania' , 'South America') , 'Continent' , 
                                   'Region')))))
wrangled_forest %>%
  arrange(desc(Entity))
wrangled_forest <- wrangled_forest %>%
  filter(land_type == 'Continent')
wrangled_forest
Africa_forest <- wrangled_forest %>%
  filter(Entity == 'Africa')
Asia_forest <- wrangled_forest %>%
  filter(Entity == 'Asia')
CA_forest <- wrangled_forest %>%
  filter(Entity == 'Central America')
Europe_forest <- wrangled_forest %>%
  filter(Entity == 'Europe')
NA_forest <- wrangled_forest %>%
  filter(Entity == 'Northern America')
Oceania_forest <- wrangled_forest %>%
  filter(Entity == 'Oceania')
SA_forest <- wrangled_forest %>%
  filter(Entity == 'South America')
continent_forest <- data.frame(Africa_forest, Asia_forest, CA_forest, Europe_forest, NA_forest, Oceania_forest, SA_forest)
continent_forest <- continent_forest %>%
  group_by('Entity')
plot_vis <- plot_ly(continent_forest, x = ~Year, y = ~forest_cover, name = 'Africa', type = 'scatter', mode = 'lines')

plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.1, name = 'Asia', type = 'scatter', mode = 'lines')
plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.2, name = 'Central America', type = 'scatter', mode = 'lines')
plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.3, name = 'Europe', type = 'scatter', mode = 'lines')
plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.4, name = 'North America', type = 'scatter', mode = 'lines')
plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.5, name = 'Ociania', type = 'scatter', mode = 'lines')
plot_vis <- plot_vis %>% add_trace(y = ~forest_cover.6, name = 'South America', type = 'scatter', mode = 'lines')


plot_vis

Reflection

What I took from Wilke to use in this project is how we are telling a story. Though fighting deforestation is a global effort, it isn't necessarily globally caused. There are places in the world in a state of reforestation, though deforestation does continue to outweigh reforestation. I wish I was able to show the change in forest cover numerically as well as graphically. Perhaps in my next attempt I'll be able to include the change from the previous year in my traces. What I found most frustrating was the amount of coding required to make the graph. I made nearly an exactly identical graph of this data for a previous project in about half the amount of code.



SammyLeeDries/regexciter documentation built on March 26, 2022, 1:44 a.m.