Description Usage Arguments Value Examples
In IPFs, common subtotals in each target must be equal, otherwise the IPF will not converge on a single result. This function checks the common dimensions over each target combination for compatibility. Further, this function checks the IPF seed, if provided, for compabitibilty with the targets. If the seed, when summed over each dimension in a given target, contains any missing values or zero values, the target must also have a zero or missing value.
1 2 | check_targets(targets, seed = NULL, target.value.names = "value",
seed.value.name = "value", max.error = 0.01)
|
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. |
seed |
An optional data frame of seed values containing all final dimensions expected as output of |
target.value.names |
The names of the series in |
seed.value.name |
The name of the series in |
max.error |
The maximum total absolute difference allowed between final scaled values and targets. |
Messages in the console and an output list of data frames containing any incompitable line items in the seed and targets.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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(x = c(rep(letters[1], 5), rep(letters[2], 5)),
z = rep(letters[6:10], 2),
value = c(5, 10, 15, 20, 0, 10, 10, 10, 10, 10))
tar.list <- list(tar1, tar2, tar3)
check_targets(tar.list)
#This will find errors with the targets
tar3b <- data.frame(x = c(rep(letters[1], 5), rep(letters[2], 5)),
z = rep(letters[6:10], 2),
value = c(0, 10, 15, 20, 0, 10, 10, 10, 10, 10))
tar.list <- list(tar1, tar2, tar3b)
seed <- ipfitr::ip_create_seed(tar.list)
check_targets(tar.list, seed)
#This will find errors with the targets and the seed
seed2 <- seed %>% mutate(value = ifelse(x == "a" & z == "g", 0, value))
check_targets(tar.list, seed2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.