#'
#'@title Compare estimated survey biomass from TCSAM2015 and rsimTCSAM model runs.
#'
#'@description Function to compare estimated survey biomass from TCSAM2015 and rsimTCSAM model runs.
#'
#'@param tcsam - single TCSAM2015 model results object, or named list of such
#'@param rsim - single rsimTCSAM results object, or named list of such
#'@param showPlot - flag to show/print plots immediately
#'@param pdf - name of pdf file to record plot output to
#'@param width - pdf page width (in inches)
#'@param height - pdf page width (in inches)
#'
#'@return list of ggplot2 objects
#'
#'@export
#'
compareModels.SurveyBiomass<-function(tcsam=NULL,
rsim=NULL,
showPlot=TRUE,
pdf=NULL,
width=8,
height=6){
#set up pdf device, if requested
if (!is.null(pdf)){
pdf(file=pdf,width=width,height=height);
on.exit(dev.close())
}
plots<-list();
#total captured (biomass)
path<-'mr/S_list/B_vyxms';
mdfr<-getMDFR(path,tcsam,rsim);
mdfr<-removeImmOS(mdfr);
mdfr$v<-gsub("_"," ",mdfr$v,fixed=TRUE);#replace '_'s in survey names with spaces
uniqVs<-unique(mdfr$v);#survey names
for (uV in uniqVs){
#plot totals across msz
mdfrp<-mdfr[mdfr$v==uV,];#select results for survey uV
ddfr<-reshape2::dcast(mdfrp,modeltype+model+v+y+x+m+s~.,fun.aggregate=NULL,na.rm=TRUE,value.var='val',drop=TRUE)
ddfr[['.']]<-ifelse(ddfr[['.']]==0,NA,ddfr[['.']]);
p<-plotMDFR.XY(ddfr,x='y',value.var='.',agg.formula=NULL,faceting='m+s~x',
title=uV,xlab='year',ylab='survey biomass',units="1000's t",lnscale=FALSE,
colour='model',guideTitleColor='model',
linetype='modeltype',guideTitleLineType='model type',
shape='modeltype',guideTitleShape='model type',
showPlot=showPlot);
plots[[uV]]$B_yx<-p;
}#uniqVs
return(invisible(plots))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.