The counterpart of scale_map() for two scales: atoms are matched on their keys, so a unit of from overlaps a unit of to where they contain the same atoms. Same columns as scale_map(), with the two label columns named after the scales. Atoms of from absent from to get an NA target (with a warning). A crosswalk registered with register_scale_map_between() is returned as-is instead of being derived.

scale_map_between(from, to, weight = NULL)

Arguments

from, to

Two named NestedScale objects whose atom keys overlap.

weight

Weight column of from for w; NULL uses its default weight, or weight 1 per atom when it declares none.

Value

A data.frame with columns <from name>, <to name>, n_from, n_overlap, w, w_from.

Examples

a <- scale_example()
b <- scale_from_leaftable(
  data.frame(
    big = c("X", "X", "Y", "Y", "Y", "Y", "Z"),
    unit = c("U1", "U2", "U3", "U4", "U5", "U6", "OTH")
  ),
  frames = c("big", "unit"), name = "other"
)
scale_map_between(a, b)
#>   example other n_from n_overlap    w w_from
#> 1     OTH   OTH      1         1 1000   1000
#> 2      U1    U1      1         1  100    100
#> 3      U2    U2      1         1  200    200
#> 4      U3    U3      1         1  300    300
#> 5      U4    U4      1         1  400    400
#> 6      U5    U5      1         1  500    500
#> 7      U6    U6      1         1  600    600