| uncount, expand_counts | R Documentation |
uncount() is provided by the tidyr package, and re-exported
by ggsurveillance. See tidyr::uncount() for more details.
uncount() and its alias expand_counts() are complements of dplyr::count(): they take
a data.frame with a column of frequencies and duplicate each row according to
those frequencies.
uncount(data, weights, ..., .remove = TRUE, .id = NULL)
expand_counts(data, weights, ..., .remove = TRUE, .id = NULL)
data |
A data frame, tibble, or grouped tibble. |
weights |
A vector of weights. Evaluated in the context of |
... |
Additional arguments passed on to methods. |
.remove |
If |
.id |
Supply a string to create a new variable which gives a unique identifier for each created row. |
A data.frame with rows duplicated according to weights.
df <- data.frame(x = c("a", "b"), n = c(2, 3))
df |> uncount(n)
# Or equivalently:
df |> expand_counts(n)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.