'Why can't I pass an anonymous function to dplyr's filter without getting errors about vector size?

Coming from base R, I expected the following to work as a way to pass anonymous functions

library(tidyverse)
starwars %>%
  select(height) %>% 
  filter(function(x) x > 100)

It does not. It reports the following:

Error in `filter()`:
! Problem while computing `..1 = function(x) x > 100`.
Caused by error in `vec_size()`:
! `x` must be a vector, not a function.
Run `rlang::last_error()` to see where the error occurred.

I suspect that I'm making a fundamental error, but I see no comparable examples in the documentation. Where is my misunderstanding of how dplyr handles such cases?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source