knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
# devtools::install_github("ices-tools-prod/fisheryO")
library(ggplot2)
library(fisheryO)
library(dplyr)

ICES Logo

fisheryO

The fisheryO package is offered to provide documentation of the processes used to download, aggregate, and analyze data for ICES Fisheries Overviews. Further, the package contains R functions to facilitate the standard plotting of these data. ICES data are available to use according to the ICES Data policy.

ICES Fisheries Overviews are available for the following ecoregions:

Installation

You can install the most recent fisheryO build from github with:

# install.packages("devtools")
# devtools::install_github("ices-tools-prod/fisheryO")
# library(fisheryO)

You can also install the raw data and code used for specific Fisheries Overviews with a "version" tag:

# install.packages("devtools")
# devtools::install_github("ices-tools-prod/fisheryO", ref = "v0.2")
# library(fisheryO)

Work flow

  1. Before the package is built, fisheryO downloads source data from ICES web services and databases and saves the raw data as .rdata files in the /data folder. This serves to create a final version of the data used to create each Fisheries Overview, thatis, (fisheryO v0.2) can be used to explore the data processing steps for the Greater North Sea ecoregion Fisheries Overview. The raw data are available as a "promise" and can be explored extracted using the data() function. The nuts and bolts of these download steps can be found in the load_raw_data.R file in the /data-raw folder and links to the raw data can be found in the description files.

  2. Raw data processing is dependent on how the data will ultimately be displayed (e.g., figure or table) and several functions modify the raw data. These functions can be viewed in the clean_raw_data.R file in the /R folder to see the assumptions and data wrangling steps to move from raw data to figures and tables.

  3. Data aggregating functions are called from within the standard plotting functions, but can be run independently to explore the intermediate data.

The list of data can be found using:

knitr::kable(as.data.frame(data(package = "fisheryO")$results[,c("Item", "Title")]))

If you want more information about the data source for each data file, use the "?" notation, e.g., ?ices_catch_historical_raw function to explore the description and to find a url for the source.

Plots

Some of the more complex plots have the option to be dynamic .html graphics with the dynamic = TRUE argument.

If you want more information about the data source used for each plot, use the "?" notation, e.g., ?plot_kobe function to explore the description.

area_definition_map("Baltic Sea Ecoregion",
                    data_caption = FALSE,
                    return_plot = TRUE,
                    save_plot = FALSE)
ices_catch_plot("Baltic Sea Ecoregion",
                data_caption = FALSE,
                type = "COUNTRY",
                line_count = 9,
                plot_type = "area",
                save_plot = FALSE,
                return_plot = TRUE,
                text.size = 9)
stecf_plot("Baltic Sea Ecoregion",
           data_caption = FALSE,
           metric = "EFFORT",
           type = "COUNTRY",
           line_count = 6,
           plot_type = "line",
           save_plot = FALSE,
           return_plot = TRUE,
           text.size = 9)

For plots using ICES Stock Assessment data, the active_year argument can be used to choose the assessment year. Baltic Sea advice for 2017 is already published, so we can use the most recent data.

guild_discards_fun("Baltic Sea Ecoregion",
                   data_caption = TRUE,
                   active_year = 2017,
                   save_plot = FALSE,
                   return_plot = TRUE)

Some stocks are fished right at FMSY and the number of decimal places can determine the status (e.g., good or bad). calculate_status = TRUE calculates the ratio of stock status relative to reference points and might result in a slightly different status than what is found in published advice. From 2017, ICES Stock Assessment Graphs database archives the stock status for each stock as a factor level (e.g., red, green, grey, orange... etc), includes qualitative and "proxy" reference points and calculate_status = FALSE should be used.

stockPie_fun("Baltic Sea Ecoregion",
             fisheries_guild = c("benthic", "demersal", "pelagic"),
             data_caption = FALSE,
             calculate_status = FALSE,
             active_year = 2017,
             save_plot = FALSE,
             return_plot = TRUE)

Plot functions also have a data_caption argument that will add the data source to the lower right corner of the margin. If you want to plot the stocks above a certain catch, the catch_limit argument can be used. This is particularly useful for ecoregions with many stocks (e.g., Greater North Sea Ecoregion).

fisheryO::plot_kobe("Greater North Sea Ecoregion", 
                    catch_limit = 10000,
                    guild = "all",
                    active_year = 2016,
                    data_caption = TRUE,
                    return_plot = TRUE,
                    save_plot = FALSE)

Stock trends can be grouped by different parameters. object specifies the group you want displayed. For the time being, group_var is necessary to point the code in the right direction to do.

fisheryO::stock_trends_fun(object = "Greater North Sea Ecoregion", 
                           plotting_var = "StockCode",
                           grouping_var = "EcoRegion",
                           metric = "MSY",
                           active_year = 2017,
                           data_caption = TRUE,
                           return_plot = TRUE,
                           save_plot = FALSE)

# fisheryO::stock_trends_fun(object = "Greater North Sea Ecoregion - demersal stocks", 
#                            plotting_var = "StockCode",
#                            grouping_var = "EcoGuild",
#                            metric = "MSY",
#                            active_year = 2017,
#                            data_caption = TRUE,
#                            return_plot = TRUE,
#                            save_plot = FALSE)
# 
# fisheryO::stock_trends_fun(object = "demersal",
#                            plotting_var = "StockCode",
#                            grouping_var = "FisheriesGuild",
#                            metric = "MSY",
#                            active_year = 2017,
#                            data_caption = TRUE,
#                            return_plot = TRUE,
#                            save_plot = FALSE)
# 
# fisheryO::stock_trends_fun(object = "Greater North Sea Ecoregion", 
#                            grouping_var = "EcoRegion",
#                            plotting_var = "FisheriesGuild",
#                            metric = "MEAN",
#                            active_year = 2017,
#                            data_caption = TRUE,
#                            return_plot = TRUE,
#                            save_plot = FALSE)

Notes

References and sources

ICES. 2017a. Historical Nominal Catches 1950–2010. Version 30-11-2011. Available at ICES website http://ices.dk/marine-data/dataset-collections/Pages/Fish-catch-and-stock-assessment.aspx. Accessed 04-07-2017.

ICES. 2017b. Official Nominal Catches 2006–2015. Version 12-06-2017. Available at ICES website http://ices.dk/marine-data/dataset-collections/Pages/Fish-catch-and-stock-assessment.aspx. Accessed 04-07-2017.

ICES. 2017c. Baltic Sea Ecoregion – Fisheries overview. In Report of the ICES Advisory Committee, 2017. ICES Advice 2017, Book 4, Section 4.2.

ICES. 2017d. Greater North Sea Ecoregion – Fisheries overview. In Report of the ICES Advisory Committee, 2017. ICES Advice 2017, Book 9, Section 9.2.

ICES Stock Assessment Graphs database: http://sg.ices.dk

ICES Stock Assessment Graphs web services: http://sg.ices.dk/webservices.aspx

ICES Stock Database: http://sd.ices.dk

ICES Stock Database web services: http://sd.ices.dk/services/

STECF. 2016. Scientific, Technical and Economic Committee for Fisheries (STECF) – Fisheries Dependent Information (STECF-16-20). Publications Office of the European Union, Luxembourg; EUR 27758 EN. 858 pp. doi:10.2788/502445.

Development

fisheryO is developed openly on GitHub.

Feel free to open an issue there if you encounter problems or have suggestions for future versions.



slarge/fisheryO documentation built on May 30, 2019, 3:04 a.m.