Simple count_if dplyr summary function
Usage
p_count_if(..., na.rm = TRUE)
Arguments
- ...
expression to be evaluated
- na.rm
ignore NA values?
Value
a count of the number of times the expression evaluated to true, in the current context
Examples
library(dplyr)
library(dtrackr)
tmp = iris %>% dplyr::group_by(Species)
tmp %>% dplyr::summarise(long_ones = p_count_if(Petal.Length > 4))
#> # A tibble: 3 × 2
#> Species long_ones
#> <fct> <dbl>
#> 1 setosa 0
#> 2 versicolor 34
#> 3 virginica 50