Single target scale function calling external dataframe.
ip_scale(datatable, target, series_start = "value", series_target = "value")
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 |
series_target | The name of the |
A dataframe with the same dimensionality as datatable
, with series_start
scaled to the subtotals specified by series_target
.
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)#>#> # 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.13df %>% ip_scale(tar1, series_start = "value", series_target = "value")#>#> # 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