Skip to content

Instantly share code, notes, and snippets.

@verajosemanuel
Last active November 14, 2017 09:38
Show Gist options
  • Save verajosemanuel/b9497e0b942866cd785a061f979ded43 to your computer and use it in GitHub Desktop.
Save verajosemanuel/b9497e0b942866cd785a061f979ded43 to your computer and use it in GitHub Desktop.
Expanding aggregates in #R #df #wrangling
df <- data.frame(x = c(2, 4, 1), y = c(9, 11, 6), n = c(3, 5, 1))
rep(1:nrow(df), df$n)
df[rep(1:nrow(df), df$n), ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment