Description Usage Arguments Value Examples
A simple function that takes the weight_tbl
output from
ipu
and randomly samples based on the weight.
1 | synthesize(weight_tbl, group_by = NULL, primary_id = "id")
|
weight_tbl |
the |
group_by |
if provided, the |
primary_id |
The field used to join the primary and secondary seed
tables. Only necessary if |
A data.frame
with one record for each synthesized member of
the population (e.g. household). A new_id
column is created, but
the previous primary_id
column is maintained to facilitate joining
back to other data sources (e.g. a person attribute table).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | hh_seed <- dplyr::tibble(
id = c(1, 2, 3, 4),
siz = c(1, 2, 2, 1),
weight = c(1, 1, 1, 1),
geo_cluster = c(1, 1, 2, 2)
)
hh_targets <- list()
hh_targets$siz <- dplyr::tibble(
geo_cluster = c(1, 2),
`1` = c(75, 100),
`2` = c(25, 150)
)
result <- ipu(hh_seed, hh_targets, max_iterations = 5)
synthesize(result$weight_tbl, "geo_cluster")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.