library(knitr) ## Global options opts_chunk$set(cache =!TRUE, echo =TRUE, eval =TRUE, prompt =FALSE, comment =NA, message =FALSE, warning =FALSE, tidy =FALSE, fig.height=6, fig.width =8) options(digits=3) iFig=0
To follow this tutorial a number of packages need to be installed, either from CRAN or from www.flr-project.org where variety of packages and tutorials are available.
install.packages(c("FLCore","FLFishery","FLasher","FLBRP","FLife","mydas"), repos="http://flr-project.org/R")
library(FLCore) library(ggplotFL) library(FLasher) library(FLBRP) library(FLife) library(mydas)
For more details on how to loading your data into FLR see the (vignette)[http://www.flr-project.org/doc/Loading_your_data_into_FLR.html]
Here life history parameters are loaded from the fishnets github repository, a library of multivariate priors for fish population dynamics parameters
load(url("https://github.com//fishnets//fishnets//blob//master//data//fishbase-web//fishbase-web.RData?raw=True"))
Select species of interest
spp=data.frame( species=c("Psetta maxima","Scophthalmus rhombus","Raja clavata", "Pollachius pollachius","Sprattus sprattus sprattus"), name= c("Turbot", "Brill", "Ray", "Pollack", "Sprat")) lh=subset(fb,as.character(species)%in%as.character(spp$species)) names(lh)[c(14,17)]=c("l50","a50")
Add common names and order by size, using name
as a factor
lh=merge(lh,spp,by="species") lh$name=factor(lh$name,levels=c("Sprat","Brill","Turbot","Pollack","Ray")) head(lh)
Parameters include von Bertanffy growth parameters ($L_{\infty}$, $k$, $b$ and $l_{50}$) length at maturity ($l_{50}$) and the length weight exponent ($b$)
library(GGally) my_smooth <- function(data,mapping,...){ ggplot(data=data,mapping=mapping)+ geom_point(...,size=.5)+ geom_smooth(...,method="lm",se=FALSE)} my_density <- function(data,mapping,...){ ggplot(data=data,mapping=mapping)+ geom_density(...,lwd=1)} #ggpairs(transmute(lh,linf=log(linf),k=log(k),l50=log(l50)), ggpairs(transform(lh[,c("name","linf","k","l50","b")],linf=log(linf),k=log(k),l50=log(l50)), mapping = ggplot2::aes(color=name), lower = list(continuous = wrap(my_smooth)), diag=list(continuous=wrap(my_density,alpha=0.2)), title = "")+ theme(legend.position ="none", panel.grid.major =element_blank(), axis.ticks =element_blank(), axis.text.x =element_blank(), axis.text.y =element_blank(), panel.border =element_rect(linetype = 1, colour="black", fill=NA))
Figure r iFig=iFig+1; iFig
Pairwise scatter plots of life history parameters.
Create an FLPar
object
par=as(lh[,c("linf","k","t0","a","b","l50")],"FLPar")
Replace NAs
par["a",is.na(par["a"])]=0.001 par["b",is.na(par["b"])]=3 par["t0"]=-0.1
Use life history relationships to estimate missing values
par=lhPar(par) attributes(par)$name=lh$name
Derive vectors for biological processses for pollack, by creating an object of class FLBRP
pollack=iter(par,attributes(par)$name=="Pollack") eql=lhEql(pollack)
ggplot(FLQuants(eql,"m","mat","catch.wt"))+ geom_line(aes(age,data,group=iter))+ facet_grid(qname~.,scale="free")+ coord_cartesian(xlim=c(0,15))+ xlab("Age")+ylab("")
Figure r iFig=iFig+1; iFig
Vectors of m, maturity and weight-at-age.
plot(eql,refpts="msy")
Figure r iFig=iFig+1; iFig
Equilibrium curves.
r version$version.string
r packageVersion('FLCore')
r packageVersion('FLBRP')
r packageVersion('FLife')
r packageVersion('mydas')
r date()
Laurence KELL. laurie.kell.es
This vignette and many of the methods documented in it were developed under the MyDas project funded by the Irish exchequer and EMFF 2014-2020. The overall aim of MyDas is to develop and test a range of assessment models and methods to establish Maximum Sustainable Yield (MSY) reference points (or proxy MSY reference points) across the spectrum of data-limited stocks.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.