Filtering across multiple columns

Does this work:

> library(dplyr)
> df %>% group_by(grp) %>% filter(!any((var1<0|var2<0) & between(wave,1,2)))
# A tibble: 3 x 4
# Groups:   grp [1]
  grp    wave  var1  var2
  <chr> <int> <dbl> <dbl>
1 c         1     1     1
2 c         2     4     4
3 c         3    -5     5
> 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top