Created
March 7, 2018 13:58
-
-
Save sfirke/8754ed62b40bc57a56aa914625d60d32 to your computer and use it in GitHub Desktop.
Using split with magrittr's $%$ to reference the names of the listed data.frames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I want to remove duplicate mpg rows where cylinder is 4 | |
# Split, tinker with the data.frames by name, bind_rows | |
library(magrittr) | |
library(dplyr) | |
mtcars %>% | |
split(., .$cyl == 4) %$% | |
bind_rows(`FALSE`, | |
`TRUE` %>% | |
distinct(mpg, .keep_all = TRUE)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment