ecd_obs_agathe = readRDS("ecd_obs_agathe.RDS")

ecd_obs_agathe$ocean_name = "Atlantic"
ecd_obs_agathe$ocean_name[ecd_obs_agathe$ocean == 2] = "Indian"

x=table(year=ecd_obs_agathe$annee_de_peche,has_obs=!is.na(ecd_obs_agathe$obs_ts),
ocean=ecd_obs_agathe$ocean_name,useNA="ifany")

x = as.data.frame(x)

y = aggregate(x["Freq"],x[c("year","ocean")],sum)

z = merge(x,y,by=c("year","ocean"),suffixes=c("","_tot"))

z$frac = z$Freq/z$Freq_tot

zz = z[z$has_obs==TRUE,]
zz$year = as.numeric(as.character(zz$year))

library(ggplot2)
ggplot(data=zz,aes(x=year,y=frac,color=ocean)) + geom_line() +
ylab("Fraction") +
scale_x_continuous(breaks=seq(2010,2020,2)) +
ggtitle("Fraction coverage of observer data") + theme_bw()