array_df_ratetable_utils {popEpi}R Documentation

arrays, data.frames and ratetables

Description

Utilities to transform objects between array, data.frame, and survival::ratetable.

Usage

long_df_to_array(x, stratum.col.nms, value.col.nm)

long_df_to_ratetable(
  x,
  stratum.col.nms,
  value.col.nm,
  dim.types,
  cut.points = NULL
)

long_dt_to_array(x, stratum.col.nms, value.col.nm)

long_dt_to_ratetable(
  x,
  stratum.col.nms,
  value.col.nm,
  dim.types,
  cut.points = NULL
)

array_to_long_df(x)

array_to_long_dt(x)

array_to_ratetable(x, dim.types, cut.points = NULL)

ratetable_to_array(x)

ratetable_to_long_df(x)

ratetable_to_long_dt(x)

Arguments

x

⁠[data.frame, data.table, array, ratetable]⁠ (mandatory, no default)

  • long_df_to_array: a data.frame

  • long_df_to_ratetable: a data.frame

  • long_dt_to_array: a data.table

  • long_dt_to_ratetable: a data.table

  • array_to_long_df: an array

  • array_to_long_dt: an array

  • array_to_ratetable: an array

  • ratetable_to_array: a survival::ratetable

  • ratetable_to_long_df: a survival::ratetable

  • ratetable_to_long_dt: a survival::ratetable

stratum.col.nms

⁠[character]⁠ (mandatory, no default)

a vector of column names in x by which values are stratified

value.col.nm

⁠[character]⁠ (mandatory, no default)

name of column in x containing values (these will be contents of the array)

dim.types

⁠[integer]⁠ (mandatory, no default)

see type under Details in survival::ratetable

cut.points

⁠[NULL, list]⁠ (optional, default NULL)

see cutpoints under Details in survival::ratetable

  • NULL: automatically set using dimnames(x) and dim.types

  • list: one element for each dimensions of x

Details

Value

Examples


long_dt <- popEpi::popmort
arr <- long_df_to_array(long_dt, c("agegroup", "year", "sex"), "haz")
rt <- array_to_ratetable(arr, dim.types = c(2L, 4L, 1L))

arr2 <- ratetable_to_array(rt)
long_df2 <- array_to_long_df(arr2)

identical(sort(long_dt[["haz"]]), sort(long_df2[["value"]]))

[Package popEpi version 0.4.13 Index]