Skip to content

Instantly share code, notes, and snippets.

@slarge
Last active March 28, 2017 10:47
Show Gist options
  • Save slarge/b69c8968a8bf32d28ab98409da72c063 to your computer and use it in GitHub Desktop.
Save slarge/b69c8968a8bf32d28ab98409da72c063 to your computer and use it in GitHub Desktop.
Exploration of Bloomberg Politics 3-26-2017 article on how fisheries might be influenced by Brexit
---
title: "UK Salmon"
author: ""
date: "28 March 2017"
output:
pdf_document: default
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE
)
library(extrafont)
library(tidyverse)
# font_import()
extrafont::loadfonts(quiet = TRUE)
library(measurements)
# devtools::install_github("hrbrmstr/hrbrthemes")
library(hrbrthemes)
library(knitr)
```
## Purpose ##
An attempt to re-create the [Bloomberg Politics](https://www.bloomberg.com/politics/articles/2017-03-26/fish-eye-view-of-the-complexities-that-may-sink-brexit-talks?bpolANews=true) article *How a Battle Over Fish Could Batter Brexit Talks* using [ICES official catch statistics](http://ices.dk/marine-data/Documents/CatchStats/). Atlantic Salmon look really (really) high and herring and mackerel look really low. A more precise data source beyond an entire government department would have been useful.
![Landings from Bloomberg](https://assets.bwbx.io/images/users/iqjWHBFdfxIU/i_pO23JDpZ7o/v1/-1x-1.png)
\pagebreak
## ICES catch statistics ##
Here, we provide fisheries statistics for the Northeast Atlantic region (Area 27) officially submitted by ICES member countries. Generally, discards are not quantified and only landings are reported.
```{r catch_dat, echo = FALSE}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# DATA SOURCE: ICES official catch statistics (2006-2014) #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
catchURL <- "http://ices.dk/marine-data/Documents/CatchStats/OfficialNominalCatches.zip"
tmpFileCatch <- tempfile(fileext = ".zip")
download.file(catchURL, destfile = tmpFileCatch, mode = "wb", quiet = TRUE)
catch_dat <- read.csv(unz(tmpFileCatch,
"ICESCatchDataset2006-2014.csv"),
stringsAsFactors = FALSE, header = TRUE, fill = TRUE)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# DATA SOURCE: FAO Species names #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
spURL <- "ftp://ftp.fao.org/FI/STAT/DATA/ASFIS_sp.zip"
tmpFileSp <- tempfile(fileext = ".zip")
download.file(spURL, destfile = tmpFileSp, mode = "wb", quiet = TRUE)
catch_dat <- left_join(catch_dat,
read.delim(unz(tmpFileSp,
"ASFIS_sp_Feb_2016.txt"),
fill = TRUE,
stringsAsFactors = FALSE, header = TRUE)[,c("X3A_CODE",
# "Scientific_name",
"English_name")],
by = c("Species" = "X3A_CODE"))
```
```{r clean_dat, include=FALSE}
catch_dat_clean <- catch_dat %>%
Filter(f = function(x)!all(is.na(x))) %>% # Get rid of extra columns of NA
select(-Units) %>%
gather(year, value, -Species, -English_name, -Area, -Country) %>%
mutate(year = as.numeric(gsub("X", "", year)),
value = as.numeric(value)/1000,
English_name = gsub("\\s*\\([^\\)]+\\)", "", English_name)) %>%
filter(Country %in% c("GB", "JE", "GG", "IM"),
Area == 27,
year == 2014)
```
```{r bar_plot, echo=FALSE, fig.cap="Landings from ICES", fig.show ='asis'}
top_ten <- catch_dat_clean %>%
group_by(English_name) %>%
summarize(totalCatch = sum(value)) %>%
arrange(totalCatch) %>%
mutate(English_name = factor(English_name, English_name)) %>%
tail(10)
ggplot(data = top_ten, aes(x = English_name, y = totalCatch)) +
geom_col() +
# geom_text(aes(label = round(totalCatch)), hjust = 0, nudge_y = 5) +
scale_y_continuous("thousand tonnes",
sec.axis = sec_axis(~ conv_unit(.,
from = "metric_ton",
to = "lbs")/ 1000,
name = "million pounds")
) +
labs(x = "", y = "",
title = "Fish and Ships - ICES",
subtitle = "Top 10 (by weight) species landed by the UK in 2014",
caption = sprintf("Source: Eurostat/ICES data compilation of catch statistics. Copenhagen, Denmark. ICES. %s / %s.",
lubridate::year(Sys.time()),
lubridate::month(Sys.time(),
label = TRUE,
abbr = FALSE))) +
coord_flip() +
# theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
theme_ipsum(grid = "X",
base_size = 9,
caption_size = 7)
```
```{r salmon_dat, include=FALSE}
salmon_total <- catch_dat_clean %>%
filter(grepl("salmon|Salmon", English_name)) %>%
group_by(English_name) %>%
summarize(totalCatch = sum(value, na.rm = TRUE))
```
Well, that is weird. Atlantic salmon isn't in the top 10 species landed by the UK! Searching the data for all Atlantic salmon landings reported by the UK in 2014, there are `r ifelse(salmon_total$totalCatch == 0, "zero", salmon_total$totalCatch)` tonnes landed. Therefore, the Atlantic salmon reported by Bloomberg must be farmed, not wild caught. Looking at the table, below, the landings are a bit different from what Bloomberg is reporting (figure 1). Differences are probably because we are aggregating over all UK countries (including Isle of Man, Jersey, Northern Ireland, and Guernseay) and potentially different areas -- we look at all of Area 27 and probably underrepresent coastal landings -- Bloomberg doesn't mention the spatial extent of their data.
```{r summary_table, echo=FALSE, results='hold'}
catch_dat_clean %>%
filter(grepl("Atlantic cod|Atlantic herring|Atlantic mackerel|Atlantic salmon|Edible crab|Norway lobster", English_name)) %>%
group_by(English_name) %>%
summarize(totalLandings = sum(value, na.rm = TRUE),
totalPounds = round(conv_unit(totalLandings,
from = "metric_ton",
to = "lbs")/ 1000 ),
totalLandings = round(totalLandings)) %>%
arrange(totalLandings) %>%
mutate(English_name = factor(English_name, English_name)) %>%
rename(`Common name` = English_name,
`Landings (thousand tonnes)` = totalLandings,
`Landings (million pounds)` = totalPounds) %>%
knitr::kable()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment