conditional_filter.Rd
Apply a filter if condition is met. This function is a simple wrapper for
filter
conditional_filter(df1, cond, varName, varCond)
df1 | A dataframe |
---|---|
cond | A logical value indicating if filter should be applied |
varName | Name of variable to filter on |
varCond | A single value for equality filter or a vector for is member filter |
Other conditional dplyr: conditional_mutate
,
conditional_range_filter
,
conditional_select
#> # A tibble: 35 x 14 #> name height mass hair_color skin_color eye_color birth_year sex gender #> <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> #> 1 Luke… 172 77 blond fair blue 19 male mascu… #> 2 Dart… 202 136 none white yellow 41.9 male mascu… #> 3 Leia… 150 49 brown light brown 19 fema… femin… #> 4 Owen… 178 120 brown, gr… light blue 52 male mascu… #> 5 Beru… 165 75 brown light blue 47 fema… femin… #> 6 Bigg… 183 84 black light brown 24 male mascu… #> 7 Obi-… 182 77 auburn, w… fair blue-gray 57 male mascu… #> 8 Anak… 188 84 blond fair blue 41.9 male mascu… #> 9 Wilh… 180 NA auburn, g… fair blue 64 male mascu… #> 10 Han … 180 80 brown fair brown 29 male mascu… #> # … with 25 more rows, and 5 more variables: homeworld <chr>, species <chr>, #> # films <list>, vehicles <list>, starships <list>#> # A tibble: 41 x 14 #> name height mass hair_color skin_color eye_color birth_year sex gender #> <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> #> 1 Luke… 172 77 blond fair blue 19 male mascu… #> 2 C-3PO 167 75 NA gold yellow 112 none mascu… #> 3 R2-D2 96 32 NA white, bl… red 33 none mascu… #> 4 Dart… 202 136 none white yellow 41.9 male mascu… #> 5 Leia… 150 49 brown light brown 19 fema… femin… #> 6 Owen… 178 120 brown, gr… light blue 52 male mascu… #> 7 Beru… 165 75 brown light blue 47 fema… femin… #> 8 R5-D4 97 32 NA white, red red NA none mascu… #> 9 Bigg… 183 84 black light brown 24 male mascu… #> 10 Obi-… 182 77 auburn, w… fair blue-gray 57 male mascu… #> # … with 31 more rows, and 5 more variables: homeworld <chr>, species <chr>, #> # films <list>, vehicles <list>, starships <list>