compress | R Documentation |
Given a data set that identifies suitable neighbors for merging, this function will merge units iteratively, where in each iteration the neighbors with the smallest reduction in terms of total M will be merged.
compress(
data,
group,
unit,
weight = NULL,
neighbors = "local",
n_neighbors = 50,
max_iter = Inf
)
data |
A data frame. |
group |
A categorical variable
contained in |
unit |
A categorical variable
contained in |
weight |
Numeric. Only frequency weights are allowed.
(Default |
neighbors |
Either a data frame or a character. If data frame, then
it needs exactly two columns, where each row identifies
a set of "neighbors" that may be merged.
If "local", considers the |
n_neighbors |
Only relevant if |
max_iter |
Maximum number of iterations (Default |
Returns a data.table.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.