Skip to content

Vignette constructing model data from output #249

@lentinj

Description

@lentinj

The core of this is converting report array back into a data.frame. You can achieve this with canned_to_data below:

canned_to_data <- function (x, col = "number") {
  dn <- names(dim(x))
  out <- as.data.frame.table(
      g3_array_agg(x, c(dn[dn != "time"], "year", "step")),
      responseName = col )
  out$year <- as.numeric(out$year)
  out$step <- as.numeric(out$step)
  if ("stock" %in% names(out)) out$stock <- as.character(out$stock)
  if ("length" %in% names(out)) levels(out$length) <- sapply(
      strsplit(levels(out$length), ":"), function (x) paste0("[", x[[1]], ",", x[[2]], ")"))
  if ("age" %in% names(out)) out$age <- as.integer(gsub("^age", "", out$age))
  return(out)
}

ldist_f_surv <- canned_to_data(canned$r$cdist_sumofsquares_ldist_f_surv_model__num)
aldist_f_surv <- canned_to_data(canned$r$cdist_sumofsquares_aldist_f_surv_model__num)
matp_f_surv <- canned_to_data(canned$r$cdist_sumofsquares_matp_f_surv_model__num)

...but there's more impedance matching than I'd like. Get rid of as much as possible, hide the rest in a g3_array_tbl, and make a vignette demonstrating how to reverse engineer the parameters we started with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions