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) iFig=0
library(mydas)
theme_set(theme_bw()) options(digits=3)
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","mpb","FLife"), repos="http://flr-project.org/R")
devtools
also needs to be installed and loaded so that the mydas
package can be installed from the GitHub repository.
install.packages("devtools",dependencies=TRUE)
library(devtools) devtools::install_github("lauriekell/mydas-pkg")
library(FLCore) library(FLasher) library(FLBRP) library(FLife) library(mydas)
Get fishbase data
stocks=data.frame( species=c("Psetta maxima","Scophthalmus rhombus","Raja clavata", "Pollachius pollachius","Sprattus sprattus sprattus"), name= c("Turbot", "Brill", "Ray", "Pollack", "Sprat")) load(url("https://github.com//fishnets//fishnets//blob//master//data//fishbase-web//fishbase-web.RData?raw=True")) finfish=subset(fb,as.character(species)%in%as.character(stock$species))
names(lh)[c(14,17)] = c("l50","a50") lh=lh[,c("linf","k","t0","a","b","a50","l50")] head(lh)
data(mydas)
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(transform(wklife[,-c(1:5)],linf=log(linf),k=log(k),l50=log(l50)), 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
wkpar=as(wklife[,6:13],"FLPar") attributes(wkpar)[names(wklife)[1:5]]=wklife[,1:5]
Then use life history relationships to estimate missing values
par <- lhPar(wkpar) units(par) <- c("", "", "cm", "", "cm", "cm", "cm", "cm")
and then to derive vectors for processses such as natural mortality
eql=lhEql(par)
sel<-function(x) catch.sel(x)%/%fapex(catch.sel(x)) ggplot(FLQuants(eql,"m","catch.sel"=sel,"mat","catch.wt"))+ geom_line(aes(age,data,col=attributes(wkpar)$name[iter]))+ facet_wrap(~qname,scale="free")+ scale_x_continuous(limits=c(0,15))+ guides(colour=guide_legend(title="Species",title.position="top"))
Figure r iFig=iFig+1; iFig
Vectors of m, selection pattern, maturity and weight-at-age.
and estimate equilibrium dynamics and reference points, e.g. for lemon sole
plot(iter(eql,3))
Figure r iFig=iFig+1; iFig
Equilibrium curves for ling.
Create a forward projection, i.e. an FLStock
from an equilibrium object
lmsl=as(iter(eql,7),"FLStock") units(mat(lmsl))="NA" units(harvest(lmsl))="f" plot(lmsl)
Figure r iFig=iFig+1; iFig
Simulate a stock with increasing F
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.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.