-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreport_plots.R
53 lines (43 loc) · 1.02 KB
/
report_plots.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
53
## Prepare plots and tables for report
## Before: data/
## summary_catch.csv
## After: report/
## sumary_catch.png
## catches_by_halfyear_bar.png
## Catches_by_halfyear_stack.png
library(icesTAF)
library(dplyr)
library(tidyr)
library(ggplot2)
mkdir("report")
# read in data
summary_catch <-
read.taf("data/summary_catch.csv")
# catch time series
taf.png("summary_catch")
print(
ggplot(data = summary_catch, aes(x = Year, y = Total)) +
geom_bar(stat = "identity", fill = taf.blue) +
ylab("Total Catch (t)") +
theme_minimal()
)
dev.off()
# catches by half year
p_halfyear <-
summary_catch %>%
select(-Total) %>%
gather(Period, Catches, "1st half", "2nd half") %>%
ggplot(aes(x = Year, y = Catches, fill = Period)) +
theme_minimal()
taf.png("catches_by_halfyear_stack")
print(
p_halfyear +
geom_area(position = 'stack')
)
dev.off()
taf.png("catches_by_halfyear_bar")
print(
p_halfyear +
geom_bar(stat = "identity", position=position_dodge())
)
dev.off()