Reshapes a long table into an array whose dimensions are the scale's axes,
in the order the product declares them, with the units as dimnames.
as_scale_array(data, x, value = NULL, frames = NULL, fill = NA, limit = 1e+07)
as_scale_table(a, x, value = "value", frames = NULL, drop_na = TRUE)A long table with one column per axis key plus the value column. Lazy inputs are materialised – an array is a dense in-memory object by definition.
A NestedScale or ScaleProduct.
Name of the value column. Defaults to the single numeric column that is not a key.
Optional named list giving the frame each axis is keyed at; defaults to each axis's atom frame.
Value for cells the data does not cover.
Refuse to allocate more than this many cells.
An array produced by as_scale_array() (or shaped like one).
Omit cells the array does not cover, rather than emitting
them as rows with NA values.
An array with one dimension per axis.
as_scale_table() returns a data.frame: one column per axis key,
plus the value column.
p <- scale_product(a = scale_example(), b = scale_example2())
d <- merge(
data.frame(unit = c("U1", "U2")),
data.frame(period = c("p1", "p2"))
)
d$v <- 1:4
as_scale_array(d, p, value = "v")
#> b
#> a p1 p2 p3 p4
#> U1 1 3 NA NA
#> U2 2 4 NA NA
#> U3 NA NA NA NA
#> U4 NA NA NA NA
#> U5 NA NA NA NA
#> U6 NA NA NA NA
#> OTH NA NA NA NA
as_scale_table(as_scale_array(d, p, value = "v"), p, value = "v")
#> unit period v
#> 1 U1 p1 1
#> 2 U2 p1 2
#> 3 U1 p2 3
#> 4 U2 p2 4