powered by
Performs the opposite opperation to dplyr::count(), duplicating rows acoording to a weighting variable (or expression).
dplyr::count()
uncount(data, weights, .remove = TRUE, .id = NULL)
A data frame, tibble, or grouped tibble.
A vector of weights. Evaluated in the context of data; supports quasiquotation.
data
If TRUE, and weights is a signle `
TRUE
weights
Supply a string to create a new variable which gives a unique identifier for each created row.
# 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) # }
Run the code above in your browser using DataLab