Wrapper function to create seed and perform iterative proportion fitting from N targets.
Combines the ip_create_seed()
and ip_fit()
functions into a single step. Creates a generic unary seed.
ip_expand(targets, target.value.names = "value", names.exclude = c("value"), value.set = 1, value.name = "value", override.warning = FALSE, max.error = 0.01, max.iterations = 25, freeze_cells = NULL, freeze_cells.value.name = "value", freeze_slice = NULL, freeze_slice.value.names = "value", minmax_cells = NULL, minmax_cells.value.names = c("value_min", "value_max"), minmax_slice = NULL, minmax_slice.value.names = c("value_min", "value_max"), minmax.smash.param = 1/3, save.tars = FALSE, show.messages = TRUE)
targets | A list of data frames containing subtotal targets. All totals in each target should be equal. Series supplied in each target will shape the final data frame. |
---|---|
target.value.names | The names of the series in |
names.exclude | Vector of names of series in targets to exclude from the data frame creation. |
value.set | Single number or vector of numbers to initialize the seed |
value.name | Name of series in the data frame containing |
max.error | The maximum total absolute difference allowed between final scaled values and targets.
Iterative scaling will complete once the error is below this threshold or |
max.iterations | The maximum number of iterations of scaling. Iterative scaling with end once this value is reached, even if the error is above |
freeze_cells | Optional data frame of values with same series columns as |
freeze_cells.value.name | The name of the series of iced values in |
freeze_slice | Optional data frame containing subtotal targets for the |
minmax_cells | Optional data frame of values with same series columns as |
minmax_cells.value.names | An array of length 2 of the names of the minimum and maximum values in |
minmax_slice | Optional data frame containing subtotal targets for the |
minmax.smash.param | Numeric value of 0 < x < 1. Following an out-of-bounds occurence for |
freeze_slice.value.name | The name or names of the series of iced values in |
minmax_slice.value.name | The name or names of the series of the minimum and maximum values in |
A dataframe with the same dimensionality as datatable
, with all values scaled to the subtotals specified in each data frame in targets
.
tar1 <- data.frame(x = letters[1:2], value = c(50, 50)) tar2 <- data.frame(y = letters[3:5], value = c(20, 40, 40)) tar3 <- data.frame(z = letters[6:10], value = c(10, 20, 30, 40, 10)) tar.list <- list(tar1, tar2, tar3) df <- ip_expand(tar.list)#>#>#> Warning: Column `x` joining character vector and factor, coercing into character vector#> Warning: Column `y` joining character vector and factor, coercing into character vector#> Warning: Column `z` joining character vector and factor, coercing into character vector#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>