Created
May 17, 2018 12:05
-
-
Save thanhleviet/0626c88375e93a396221442cbf21e8a7 to your computer and use it in GitHub Desktop.
Subset with multiple conditions
This file contains hidden or 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
mtcars %>% | |
mutate( | |
selected = case_when( | |
cyl == 6 & carb == 4 ~ "yes", | |
cyl == 8 & carb == 8 ~ "yes", | |
TRUE ~ "no" | |
) | |
) %>% | |
filter(selected == "yes") %>% | |
select(-selected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment