http://rpubs.com/pl202/436164
library(knitr) ## Global options opts_chunk$set(cache =TRUE, cache.path='cache/performance/', echo =TRUE, eval =TRUE, prompt =FALSE, comment =NA, message =FALSE, warning =FALSE, tidy =FALSE, fig.height=6, fig.width =8, fig.path ='tex/performance-') iFig=0
library(ggplotFL) library(plyr) library(reshape) library(FLBRP) library(FLife)
theme_set(theme_bw()) options(digits=3)
To follow this tutorial you will have to install a number of packages, either from CRAN or from www.flr-project.org where variety of packages and tutorials are available.
Install FLR from https://www.flr-project.org/
install.packages(c("FLCore","FLFishery","FLasher","FLBRP","mpb","FLife"), repos="http://flr-project.org/R")
devtools
needs to be installed and then loaded so that the mydas
package can be installed from this GitHub repository.
install.packages("devtools",dependencies=TRUE)
library(devtools) devtools::install_github("lauriekell/mydas-pkg")
library(plyr) library(reshape) library(ggplot2)
library(FLCore) library(FLasher) library(FLBRP) library(FLife) library(mydas)
options(scipen = 999) library(DBI) library(RPostgreSQL) drv = dbDriver("PostgreSQL") con = dbConnect(drv, host = 'postgresql-seascope.csffkpr9jjjn.eu-west-2.rds.amazonaws.com', dbname='FLRout', port = 5432, user = 'MydasApplication', password = 'gmit2017!') mpb = dbGetQuery(con1, paste("select* from mpb where spp = 'turbot' and year < 94")) ss_labels = c("0.7"="Ftar=0.7", "1"="Ftar=1") ggplot(mpb, aes(as.factor(year), ssb/msy_ssb,fill=as.factor(btrig)))+ geom_boxplot(outlier.size=0.1, position=position_dodge(1),width=0.8, lwd=0.05, notch=TRUE)+ stat_summary(fun.y=mean, geom="line", aes(group=1))+ geom_hline(aes(yintercept=1), size=0.75, colour= "red", linetype="dashed")+ facet_wrap(~ftar,ncol=1, labeller = labeller(ftar = ss_labels),scale="free_y") + theme_bw() + theme(panel.grid.major = element_blank(), text = element_text(size=14), panel.grid.minor = element_blank(), strip.background = element_blank(), panel.border = element_rect(colour = "black"), legend.position="bottom") + scale_colour_manual(values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_fill_manual(name=expression(B[trig]),values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_x_discrete(breaks = c(50,60,70,80,90))+ scale_y_continuous(breaks = c(0:5))+ xlab("year")+ylab(expression(B/B[MSY])) ggplot(mpb, aes(as.factor(year), catch/msy_yield,fill=as.factor(btrig)))+ geom_boxplot(outlier.size=0.1, position=position_dodge(1),width=0.8, lwd=0.05, notch=TRUE)+ stat_summary(fun.y=mean, geom="line", aes(group=1))+ geom_hline(aes(yintercept=1), size=0.75, colour= "red", linetype="dashed")+ facet_wrap(~ftar,ncol=1, labeller = labeller(ftar = ss_labels),scale="free_y") + theme_bw() + theme(panel.grid.major = element_blank(), text = element_text(size=14), panel.grid.minor = element_blank(), strip.background = element_blank(), panel.border = element_rect(colour = "black"), legend.position="bottom") + scale_colour_manual(values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_fill_manual(name=expression(B[trig]),values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_x_discrete(breaks = c(50,60,70,80,90))+ scale_y_continuous(breaks = c(0:5))+ xlab("year")+ylab(expression(catch/catch[MSY])) ggplot(mpb,aes(as.factor(year), fbar/msy_harvest,fill=as.factor(btrig)))+ geom_boxplot(outlier.size=0.1, position=position_dodge(1),width=0.8, lwd=0.05, notch=TRUE)+ stat_summary(fun.y=mean, geom="line", aes(group=1))+ geom_hline(aes(yintercept=1), size=0.75, colour= "red", linetype="dashed")+ facet_wrap(~ftar,ncol=1, labeller = labeller(ftar = ss_labels),scale="free_y") + theme_bw() + theme(panel.grid.major = element_blank(), text = element_text(size=14), panel.grid.minor = element_blank(), strip.background = element_blank(), panel.border = element_rect(colour = "black"), legend.position="bottom") + scale_colour_manual(values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_fill_manual(name=expression(B[trig]),values=c("white", "#56B4E9"), labels=c("0.5","0.6")) + scale_x_discrete(breaks = c(50,60,70,80,90))+ scale_y_continuous(breaks = c(0:5))+ xlab("year")+ylab(expression(f/f[MSY]))
Figure r iFig=iFig+1; iFig
r version$version.string
r packageVersion('FLCore')
r # packageVersion('FLPKG')
r date()
r system("git log --pretty=format:'%h' -n 1", intern=TRUE)
Laurence KELL. laurie@seaplusplus.co.uk
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.