Single target scale function calling external dataframe.

ip_scale(datatable, target, series_start = "value", series_target = "value")

Arguments

datatable

A dataframe of values to be scaled to target.

target

A dataframe of target subtotals over one or more dimensions.

series_start

The name of the series in datatable to be scaled to the target.

series_target

The name of the target series.

Value

A dataframe with the same dimensionality as datatable, with series_start scaled to the subtotals specified by series_target .

Examples

df <- data.frame(x = rep(letters[1:2], 2), y = c(rep("c", 2), rep("d", 2)), value = runif(4)) tar1 <- data.frame(x = letters[1:2], value = c(20, 30)) ip_scale(df, tar1)
#> Joining, by = "x"
#> # A tibble: 4 x 3 #> x y value #> <fct> <fct> <dbl> #> 1 a c 16.3 #> 2 b c 28.9 #> 3 a d 3.69 #> 4 b d 1.13
df %>% ip_scale(tar1, series_start = "value", series_target = "value")
#> Joining, by = "x"
#> # A tibble: 4 x 3 #> x y value #> <fct> <fct> <dbl> #> 1 a c 16.3 #> 2 b c 28.9 #> 3 a d 3.69 #> 4 b d 1.13