-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.R
52 lines (35 loc) · 1.76 KB
/
data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Initial formatting of the data
library(icesTAF)
taf.library(icesFO)
library(dplyr)
mkdir("data")
# load species list
species_list <- read.taf("bootstrap/data/FAO_ASFIS_species/species_list.csv")
sid <- read.taf("bootstrap/data/ICES_StockInformation/sid.csv")
# 1: ICES official cath statistics
hist <- read.taf("bootstrap/data/ICES_nominal_catches/ICES_historical_catches.csv")
official <- read.taf("bootstrap/data/ICES_nominal_catches/ICES_2006_2017_catches.csv")
prelim <- read.taf("bootstrap/data/ICES_nominal_catches/ICES_preliminary_catches.csv")
catch_dat <-
format_catches(2019, "Baltic Sea",
hist, official, prelim, species_list, sid)
write.taf(catch_dat, dir = "data", quote = TRUE)
# 2: STECF effort and landings
effort <- read.taf("bootstrap/data/STECF_effort.csv", check.names = TRUE)
landings <- read.taf("bootstrap/initial/data/STECF_landings.csv", check.names = TRUE)
frmt_effort <- format_stecf_effort(effort)
frmt_landings <- format_stecf_landings(landings)
write.taf(frmt_effort, dir = "data", quote = TRUE)
write.taf(frmt_landings, dir = "data")
# 3: SAG
sag_sum <- read.taf("bootstrap/data/SAG_data/SAG_summary.csv")
sag_refpts <- read.taf("bootstrap/data/SAG_data/SAG_refpts.csv")
sag_status <- read.taf("bootstrap/data/SAG_data/SAG_status.csv")
clean_sag <- format_sag(sag_sum, sag_refpts, 2019, "Baltic")
clean_status <- format_sag_status(sag_status, 2019, "Baltic Sea")
# remove some stocks
Baltic_Out_stocks <- c("sal.27.32", "sal.27.22-31", "ele.2737.nea", "trs.27.22-32", "her.27.30", "her.27.31")
clean_sag <- dplyr::filter(clean_sag, !StockKeyLabel %in% Baltic_Out_stocks)
clean_status <- dplyr::filter(clean_status, !StockKeyLabel %in% Baltic_Out_stocks)
write.taf(clean_sag, dir = "data")
write.taf(clean_status, dir = "data", quote = TRUE)