uncount

0th

Percentile

"Uncount" a data frame

Performs the opposite operation to dplyr::count(), duplicating rows according to a weighting variable (or expression).

Usage
uncount(data, weights, .remove = TRUE, .id = NULL)
Arguments
data

A data frame, tibble, or grouped tibble.

weights

A vector of weights. Evaluated in the context of data; supports quasiquotation.

.remove

If TRUE, and weights is a single

.id

Supply a string to create a new variable which gives a unique identifier for each created row.

Aliases
  • uncount
Examples
# NOT RUN {
df <- tibble::tibble(x = c("a", "b"), n = c(1, 2))
uncount(df, n)
uncount(df, n, .id = "id")

# You can also use constants
uncount(df, 2)

# Or expressions
uncount(df, 2 / n)
# }
Documentation reproduced from package tidyr, version 0.8.2, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.