moodymudskipper / tb

IN ~PROGRESS my own take on `[.data.frame`
0 stars 0 forks source link

better filter_all, filter_at ? #39

Open moodymudskipper opened 4 years ago

moodymudskipper commented 4 years ago

We proposed something but we might be able to do better:

We could use the formula "along" notation, for the if / at condition. _all would be simulated by using the dot. It would be nice to have a compact way of saying all_vars or any_vars on either side, maybe a double formula ?

# dplyr
filter_all(mtcars[1:10,], all_vars(. > 200))
# tb + MatrixStats
mtcars[1:10, ] %tb>% .[rowAlls(.data > 200),]
# tentative proposal
mtcars[1:10, ] %tb>% .[. > 200 ~all~ . ,]

# dplyr
filter_all(mtcars[1:10,], any_vars(. > 200))
# tb + MatrixStats
mtcars[1:10, ] %tb>% .[rowAnys(.data > 200),]
# tentative proposal
mtcars[1:10, ] %tb>% .[. > 200 ~any~ . ,]