Common mistakes

  • Mistake: Using = instead of ==
    • filter() tells you when this happens (read the errors!):
flights |> 
  filter(month = 1)
#> Error in `filter()`:
#> ! We detected a named input.
#> ℹ This usually means that you've used `=` instead of `==`.
#> ℹ Did you mean `month == 1`?

Mistake: Writing “or” statements like you would in English:

flights |> 
  filter(month == 1 | 2)
# "filter where (month is 1), or (2 (is a non-zero number))"
# Equivalent to filter((month == 1) | TRUE)

instead of:

flights |> 
  filter(month == 1 | month == 2)
# "filter where month is 1 or month is 2"