traj_list_to_df: Turn a nested list of projections into a single dataframe

View source: R/28_traj_list_to_df.R

traj_list_to_dfR Documentation

Turn a nested list of projections into a single dataframe

Description

This function is for any case where the user wants to pull the projection outputs out of their nested list format. In the Shiny app, it is used to generate a simple table of raw outputs in case users want to create their own plots.

Usage

traj_list_to_df(x)

Arguments

x

A nested list of projections, with depletion levels nested within bycatch levels.

Value

a dataframe containing projection outputs, initial depletion levels, and bycatch levels.

Examples

 parms <- list(S0 = 0.944, S1plus = 0.99, K1plus = 9000, AgeMat = 18,
nages = 25, z = 2.39, lambdaMax = 1.02)
nyears <- 50
initdepl.vec <- c(0.2, 0.5, 0.9)
high.list.const <- lapply(
  X = initdepl.vec,
  function(x) {
    projections(
      NOut = 50,
      ConstantBycatch = list(Catch = 25, CV = 0.3),
      InitDepl = x,
      lh.params = parms,
      nyears = nyears,
      obs_CV = 0.1
    )
  }
)
med.list.const <- lapply(
  X = initdepl.vec,
  function(x) {
    projections(
      NOut = 50,
      ConstantBycatch = list(Catch = 12, CV = 0.3),
      InitDepl = x,
      lh.params = parms,
      nyears = nyears,
      obs_CV = 0.1
    )
  }
)
low.list.const <- lapply(
  X = initdepl.vec,
  function(x) {
    projections(
      NOut = 50,
      ConstantBycatch = list(Catch = 2, CV = 0.3),
      InitDepl = x,
      lh.params = parms,
      nyears = nyears,
      obs_CV = 0.1
    )
  }
)
zero.list.const <- lapply(
  X = initdepl.vec,
  function(x) {
    projections(
      NOut = 50,
      ConstantBycatch = list(Catch = 0, CV = 0),
      InitDepl = x,
      lh.params = parms,
      nyears = nyears,
      obs_CV = 0.1
    )
  }
)
traj.list <- list(
  high.list.const,
  med.list.const,
  low.list.const,
  zero.list.const
)


mcsiple/mmrefpoints documentation built on June 17, 2022, 8:41 p.m.