Suppose I have a dataframe like this one:
library(tibble)
df <- tribble (
~ day, ~ event,
1, 3,
2, 1,
3, 4)
And I want to obtain this:
output <- tribble(
~ day,
1,
1,
1,
2,
3,
3,
3,
3)
We could do this in base R:
output <- data.frame(day = rep(df$day, df$event))
But is there a tidyverse way to do it?