Skip to content

Instantly share code, notes, and snippets.

@jxu
Last active November 27, 2024 21:25
Show Gist options
  • Save jxu/30434b9e41bcf382de555a99db311bbb to your computer and use it in GitHub Desktop.
Save jxu/30434b9e41bcf382de555a99db311bbb to your computer and use it in GitHub Desktop.
library(tidyverse)
# find duplicates by col
df %>% filter(n() > 1, .by = "col")
# drop duplicates by col
df %>% distinct(col)
# summarize per group by
mtcars %>%
group_by(cyl) %>%
summarize(mean = mean(disp), n = n())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment