Help conditional length function

Hi, and welcome.

Please review the FAQ: What's a reproducible example (`reprex`) and how do I do one? This leads to better answers.

Using dplyr on a data frame, to get the count of rows meeting some condition, the filter() function piped to count() will get you a summary like this

suppressPackageStartupMessages(library(dplyr)) 
(mtcars %>% filter(mpg <= 25 & wt >= 3.500) %>% count())
#> # A tibble: 1 x 1
#>       n
#>   <int>
#> 1    11

Created on 2020-02-24 by the reprex package (v0.3.0)

1 Like