The bare pipeline verb, dispatching on the scale so one entry point serves
a NestedScale, a ScaleProduct, and the dimension subclasses in
timescales and geoscales, which register their own methods against this
generic. recast_scale() and recast_product() are the explicit
workers.
recast(x, scale, ...)The data to recast.
The scale to recast through.
Passed to the dispatched method: for a NestedScale the
arguments of recast_scale(), with target the target frame and
source the source frame (inferred when omitted); for a
ScaleProduct those of recast_product().
The recast data, in the input's class.
The scale is scale; the source frame is source and the target target,
as in recast_scale(), so a call reads the same through the generic and
through the worker.
s <- scale_example()
d <- data.frame(
unit = c("U1", "U2", "U3", "U4", "U5", "U6"),
capacity = c(1, 2, 3, 4, 5, 6)
)
recast(d, s, target = "sector", rule = "sum")
#> sector capacity
#> 1 P 10
#> 2 S 11