library(knitr)
output <- opts_knit$get("rmarkdown.pandoc.to")
usingLatex <- (output=="latex") 

fig <- local({
    i <- 0
    ref <- list()
    list(
        cap=function(refName, text) {
            i <<- i + 1
            ref[[refName]] <<- i
            if(! usingLatex) {
              paste("Figure ", i, ": ", text, sep="")
            }else{
              text
            }
        },
        ref=function(refName) {
            ref[[refName]]
        })
})
tab <- local({
    i <- 0
    ref <- list()
    list(
        cap=function(refName, text) {
            i <<- i + 1
            ref[[refName]] <<- i
            if(! usingLatex) {
              paste("Tableau ", i, ": ", text, sep="")
            }else{
              text
            }
        },
        ref=function(refName) {
            ref[[refName]]
        })
})

\begin{centering} \section{Fit of catch data} \end{centering}

pic = plot(object, what = "output", var = "totalCatch", 
           scales = list(x = list(cex = 2), y = list(cex = 2)), main = "", 
           xlab = list(label = "Years", cex = 2), ylab = list(label = "Catch in kt", cex = 2), 
           plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
} else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "catchResidualsByFleet",
           scales = list(x = list(cex = 2), y = list(cex = 2)),
           main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Residuals", cex = 2),
           plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1)))) 
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "absoluteResidualCatchByFleet",
           scales = list(x = list(cex = 2), y = list(cex = 2)), 
           main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "model - obs", cex = 2),
           plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1.5, 1))))  
}else{
  do.call(grid.arrange, pic)
}
# pic = plot(object, what = "output", var = "residualsCatchAtLengthByFleet",
#            scales = list(x = list(cex = 2), y = list(cex = 2)),
#            main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "model - obs", cex = 2), 
#            plot = FALSE)
# if(length(pic) != 1){
# do.call(grid.arrange, c(pic, list(heights = c(1.5, 1))))  
# }else{
#   do.call(grid.arrange, pic)
# }
# pic = plot(object, what = "output", var = "lengthFitsCatch",
#            scales = list(x = list(cex = 2), y = list(cex = 2)), 
#            main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "model - obs", cex = 2),
#            plot = FALSE)
# if(length(pic) != 1){
# do.call(grid.arrange, c(pic, list(heights = c(1.5, 1))))  
# }else{
#   do.call(grid.arrange, pic)
# }
pic = plot(object, what = "output", var = "predictedObservedCatchesByFleet",
           scales = list(x = list(cex = 2), y = list(cex = 2)), 
           main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Thousands tons", cex = 2),
           plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
 do.call(grid.arrange, pic) 
}

\newpage \begin{centering} \section{Fit of survey data} \end{centering} \vspace{2cm}

pic = plot(object, what = "output", var = "predictedObservedIndices",
           scales = list(x = list(cex = 1), y = list(cex = 1)), 
           main = "", xlab = list(label = "Years", cex = 1.5), ylab = list(label = "Normalized index value", cex =
                                                                             1.5),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "standardizedSurveyResiduals",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Log residuals", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "sdPerInputSeries",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "SD", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1))))  
}else{
  do.call(grid.arrange, pic)
}

\newpage \begin{centering} \section{Fleet and Survey Sel and $F$} \end{centering} \vspace{2cm}

pic = plot(object, what = "output", var = "selectivityFisheryByPentad",
      scales = list(x = list(cex = 1), y = list(cex = 1)), 
      main = "", xlab = list(label = "Age", cex = 2), ylab = list(label = "Selectivity", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "selectivitySurveyByPentad",
      scales = list(x = list(cex = 1), y = list(cex = 1)), 
      main = "", xlab = list(label = "Age", cex = 2), ylab = list(label = "Selectivity", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(2, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "fAtAGe", scales = list(x = list(cex = 0.5), y = list(cex = 0.5)),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "fProportionAtAGe",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Proportion of F at age", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "nAtAGe", 
           scales = list(x = list(cex = 0.5), y = list(cex = 0.5)), 
           main = "", xlab = list(label = "Years", cex = 1), ylab = list(label = "N at Age", cex = 1),
           plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic  = plot(object, what = "output", var = "nProportionAtAGe",
            scales = list(x = list(cex = 2), y = list(cex = 2)),
            main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Proportion of N at age", cex = 2),
            plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1.5, 1))))  
}else{
  do.call(grid.arrange, pic)
}
# pic = plot(object, what = "output", var = "fisheryMeanLength",
#            scales = list(x = list(cex = 2), y = list(cex = 2)),
#            main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "model - obs", cex = 2),
#            plot = FALSE)
# if(length(pic) != 1){
# do.call(grid.arrange, c(pic, list(heights = c(1.5, 1))))  
# }else{
#   do.call(grid.arrange, pic)
# }

\newpage \begin{centering} \section{Stock summary} \end{centering} \vspace{2cm}

pic = plot(object, what = "output", var = "summarySheet2",
      scales = list(x = list(cex = 1), y = list(cex = 1)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "data", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "uncertaintyKeyParams",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "CV", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "matureInmatureFishes",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Biomass in kt", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "stockRecruitment",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Spawning Stock Biomass", cex = 2), ylab = list(label = "Recruitment", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}
pic = plot(object, what = "output", var = "fishedUnfishedBiomass",
      scales = list(x = list(cex = 2), y = list(cex = 2)), 
      main = "", xlab = list(label = "Years", cex = 2), ylab = list(label = "Total Biomass", cex = 2),
      plot = FALSE)
if(length(pic) != 1){
do.call(grid.arrange, c(pic, list(heights = c(1, 1))))  
}else{
  do.call(grid.arrange, pic)
}


SPRFMO/jjmr documentation built on March 27, 2024, 6:16 a.m.