World Bank Development Indicator
Top 10 countries:
Indonesia - 185
Madagascar - 119
Mexico - 101
India - 93
Brasil - 82
China - 74
Malaysia - 70
Colombia - 56
Australia - 56
Peru - 55
The distribution of countries shows Africa, America and Asia have countries with more mammal species threatened. Countries with lower GDP generally have more mammal species threatened, except for Oceania.
European countries - which have higher GDP and higher percetage of water protected - have the fewer fish species threatened.
European countries - which have higher GDP and higher percetage of water protected - have the fewer fish species threatened. Top 10 countries in with fish species threatened:
South Africa - 247
Australia - 216
Cameroon - 179
China - 175
Turkey - 150
Indonesia - 131
Tanzania - 131
Mexico - 119
India - 111
United States - 103
---
title: "ANLY512_narrative_storyboard.rmd"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source: embed
storyboard: true
---
World Bank Development Indicator
### Where Are Mammal Species Threatened
```{r}
indicators <- read.csv("/Users/yh101251/Desktop/HU/512/week10/indicators.csv")
```
```{r}
library(dplyr)
threatened=filter(indicators, IndicatorCode %in% c("EN.MAM.THRD.NO","EN.BIR.THRD.NO","EN.FSH.THRD.NO","EN.HPT.THRD.NO","NY.GDP.PCAP.CD","ER.MRN.PTMR.ZS"))
#mammal species, bird species, fish species, plant species, GDP per capita, marine protected water
library(countrycode)
threatened$continent <- factor(countrycode(sourcevar = threatened[, "CountryName"],
origin = "country.name",
destination = "continent"))
library(zoo)
library(tidyr)
threatened_wide <- threatened %>%
spread(IndicatorCode, Value) %>%
group_by(CountryName) %>%
mutate_all(funs(na.locf(., na.rm = FALSE, fromLast = FALSE)))%>%filter(row_number()==n())
## after spread()
## CountryName Var1 Var2 Var3 Var4 Var5
## A 12 11 33 NA NA
## A 112 115 NA NA NA
## reference: Combine rows by group with differing NAs in each row: https://stackoverflow.com/questions/45201654/combine-rows-by-group-with-differing-nas-in-each-row
threatened_wide_matched <- na.omit(threatened_wide)
```
```{r echo=F, results='hide'}
library(rworldmap)
##Joining data to a country map
matched <- joinCountryData2Map(as.data.frame(threatened_wide_matched),joinCode = "ISO3",nameJoinColumn = "CountryCode")
```
```{r}
##displaying the data
par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i")
mapCountryData(matched, nameColumnToPlot="EN.MAM.THRD.NO", mapTitle = "Number of Mammal Species Threatened in 2015",catMethod = "pretty",colourPalette = "topo")
```
```{r echo=F, results='hide'}
attach(threatened_wide_matched)
newdata <- threatened_wide_matched[order(EN.MAM.THRD.NO),]
tail(newdata,10)
```
***
Top 10 countries:
Indonesia - 185
Madagascar - 119
Mexico - 101
India - 93
Brasil - 82
China - 74
Malaysia - 70
Colombia - 56
Australia - 56
Peru - 55
### Relationship between GDP and threatened mammal species
```{r}
library(ggplot2)
library(ggthemes)
ggplot(data =threatened_wide_matched, aes(x=NY.GDP.PCAP.CD, y= EN.MAM.THRD.NO,colour=continent, alpha = 0.5)) +
geom_point() +
geom_smooth(method='lm',formula=y~x) +
facet_wrap(~continent) +
theme_bw() +
labs(x="GDP per capita", y="Number of species threatened", title = "GDP per capita and Mammal Species Threatened")
```
***
The distribution of countries shows Africa, America and Asia have countries with more mammal species threatened.
Countries with lower GDP generally have more mammal species threatened, except for Oceania.
### Relationship between GDP, fish species and protected water
```{r}
library(ggplot2)
library(ggthemes)
ggplot() +
geom_point(data = threatened_wide_matched, aes(x=NY.GDP.PCAP.CD, y=ER.MRN.PTMR.ZS, colour=continent, size = EN.FSH.THRD.NO), alpha = 0.5) +
geom_smooth(method='lm',formula=y~x) +
labs(title = "Relationship: Fish Species Threatened and Protected Water", subtitle = "Each point represents one country", x="GDP per Capita in U.S. $", y = "Percentage of Water Protected") +
theme_bw()
```
***
European countries - which have higher GDP and higher percetage of water protected - have the fewer fish species threatened.
### Protected water and threatened fish species
```{r}
library(ggplot2)
library(ggthemes)
ggplot(data = threatened_wide_matched, aes(x=ER.MRN.PTMR.ZS, y=EN.FSH.THRD.NO, colour = continent, alpha = 0.5)) +
geom_point() +
geom_smooth(method='lm',formula=y~x) +
labs(title = "Relationship: Protected Water and Fish Species Threatened", subtitle = "Each point represents one country", x="Percentage of Marine Water Protected", y = "Number of Species Threatened") +
theme_bw() +
facet_wrap(~continent)
```
```{r echo=F, results='hide'}
attach(threatened_wide_matched)
newdata <- threatened_wide_matched[order(EN.FSH.THRD.NO),]
tail(newdata,10)
```
***
European countries - which have higher GDP and higher percetage of water protected - have the fewer fish species threatened.
Top 10 countries in with fish species threatened:
South Africa - 247
Australia - 216
Cameroon - 179
China - 175
Turkey - 150
Indonesia - 131
Tanzania - 131
Mexico - 119
India - 111
United States - 103