Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > df <- data.frame(x = c(1,1,2,2,2,3,3,3,4,4, NA))
- >
- > df
- x
- 1 1
- 2 1
- 3 2
- 4 2
- 5 2
- 6 3
- 7 3
- 8 3
- 9 4
- 10 4
- 11 NA
- >
- > df %>%
- + group_by(x) %>%
- + summarise(sum(x))
- # A tibble: 5 x 2
- x `sum(x)`
- <dbl> <dbl>
- 1 1 2
- 2 2 6
- 3 3 9
- 4 4 8
- 5 NA NA
Add Comment
Please, Sign In to add comment