when we get a data frame from an expression in filter()
perhaps we should &
all its columns, this would enable something like
library(dplyr, warn.conflicts = FALSE) iris %>% filter(across(starts_with("Sepal"), ~ . > 4)) #> Error: filter() expressions should return logical vectors of the same size as the group iris %>% filter(Sepal.Length > 4 & Sepal.Width > 4) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.7 4.4 1.5 0.4 setosa #> 2 5.2 4.1 1.5 0.1 setosa #> 3 5.5 4.2 1.4 0.2 setosa iris %>% filter_at(vars(starts_with("Sepal")), all_vars(. > 4)) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.7 4.4 1.5 0.4 setosa #> 2 5.2 4.1 1.5 0.1 setosa #> 3 5.5 4.2 1.4 0.2 setosa
Created on 2019-12-30 by the reprex package (v0.3.0.9000)
This might be a better model than the current strategy of tricking ...
into a single expression with all_exprs()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4