library(tidyverse)
<-
df tribble(~"name", ~"count",
"John", 1,
"Jane", 4,
"James", 2)
df
# A tibble: 3 × 2
name count
<chr> <dbl>
1 John 1
2 Jane 4
3 James 2
Sharon Howard
1 Mar 2023
Problem: I had a dataset in which values had been summarised, but for a particular analysis I wanted to dis-aggregate them.
Solution: tidyr::uncount(). Does the opposite of dplyr::count().
# A tibble: 3 × 2
name count
<chr> <dbl>
1 John 1
2 Jane 4
3 James 2