array_df_ratetable_utils | R Documentation |
array
s, data.frame
s and ratetable
sUtilities to transform objects between array
, data.frame
, and
survival::ratetable.
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)
x |
|
stratum.col.nms |
a vector of column names in |
value.col.nm |
name of column in |
dim.types |
see |
cut.points |
see
|
long_df_to_array
: converts a long-format data.frame
to an array
with one or more dimensions
long_df_to_ratetable
: calls long_df_to_array
and then
array_to_ratetable
long_dt_to_array
: simply asserts that x
is a data.table
and
calls long_df_to_array
long_dt_to_ratetable
: calls long_dt_to_array
and then
array_to_ratetable
array_to_long_df
: converts an array with one or more dimensions into
a long-format data.frame
; any dimnames are used to name and fill the
stratifying columns; for dimensions without a name, ".dX"
is used
for stratifying column number X
; for each k
, if there are no contents
in dimnames(x)[[k]]
, the elements of seq(dim(x)[k])
are used to fill
the corresponding stratifying column; the value column always has the name
"value"
array_to_long_dt
: calls array_to_long_df
and converts result to a
data.table
for convenience
array_to_ratetable
: converts an array to a survival::ratetable
ratetable_to_array
: converts a survival::ratetable to an array
ratetable_to_long_df
: calls ratetable_to_array
and then
array_to_long_df
ratetable_to_long_dt
: calls ratetable_to_array
and then
array_to_long_dt
long_df_to_array
: an array
long_df_to_ratetable
: a survival::ratetable
long_dt_to_array
: an array
long_dt_to_ratetable
: a survival::ratetable
array_to_long_df
: an data.frame
array_to_long_dt
: an data.table
array_to_ratetable
: a survival::ratetable
ratetable_to_array
: an array
ratetable_to_long_df
: a data.frame
ratetable_to_long_dt
: a data.table
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"]]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.