Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = structure(list(Group = c(1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3,
- 3), index = c(1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3)), row.names = c(NA,
- -13L), class = c("tbl_df", "tbl", "data.frame"))
- df = structure(list(Group = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1), index = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4,
- 4, 4, 4)), row.names = c(NA, -16L), class = c("tbl_df", "tbl",
- "data.frame"))
- df = structure(list(Group = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1), index = c(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1,
- 2, 3, 4)), row.names = c(NA, -16L), class = c("tbl_df", "tbl",
- "data.frame"))
- library(dplyr)
- df %>%
- group_by(Group) %>%
- slice(rep(seq_len(n()), each = n()))
- df %>%
- group_by(Group) %>%
- slice(rep(seq_len(n()), n()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement