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, from, ...)The data to recast.
The scale to recast through.
Passed to the dispatched method: for a NestedScale the arguments of
recast_scale(), with to the target frame and from_frame the source
frame (inferred when omitted); for a ScaleProduct those of
recast_product().
The recast data, in the input's class.
from is the SCALE, matching the convention the dimension packages
established. The source FRAME – recast_scale()'s own from – is
from_frame here, mirroring geoscales' from_geoframe.
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, to = "sector", rule = "sum")
#> sector capacity
#> 1 P 10
#> 2 S 11