Last active
August 9, 2026 04:13
-
-
Save briandk/c254a40064f1845d9b40a71726b56e3a to your computer and use it in GitHub Desktop.
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
| library(dplyr) | |
| # The full `starwars` tibble should have 87 rows ---- | |
| nrow(starwars) | |
| # `filter()`-ing on it Works Predictably ---- | |
| ## This should result in a 1-row tibble with Jabba the Hutt | |
| filter(starwars, !is.na(mass), mass > 1000) | |
| ## And we can check the number of rowsto confirm it's 1 | |
| filter(starwars, !is.na(mass), mass > 1000) |> | |
| nrow() | |
| # But I'm having problems with `filter_out()` ---- | |
| ## This should result in a 1-row tibble with Jabba the Hutt. | |
| ## All I've done is flip the conditions from the original `filter()` | |
| ## Instead, it returns the full starwars tibble | |
| filter_out(starwars, is.na(mass), mass < 1000) | |
| # And again, we can check the number of rows and see it's 87 | |
| filter_out(starwars, is.na(mass), mass < 1000) |> | |
| nrow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment