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, ...)

Arguments

x

The data to recast.

from

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().

Value

The recast data, in the input's class.

Details

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.

Examples

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