I have a dataset with a bunch of times. Let's say I wanted to create a summary table that counts number of rows satisfying "less than" filter for a sequence of values, say [number of rows with time < 6, number of rows with time < 7, etc.]
Example dataset:
data.frame(personId = c("2009ZEMD01", "2012PARK03", "2017VILL41", "2010WEYE01", "2016KOLA02", "2012PONC02"),
average = c(553, 559, 598, 606, 612, 613))
This was my solution using sapply:
tibble(time = 6:15,
count = sapply(time, function(t) best_3x3_solvers %>% filter(average/100 < t) %>% nrow))
The result:
> solvers_under
# A tibble: 10 x 2
time count
<int> <int>
1 6 3
2 7 48
3 8 274
4 9 840
5 10 1952
6 11 3792
7 12 6269
8 13 9459
9 14 13204
10 15 17274
The code is not too long but is there a method using more tidyverse tools without *apply? Maybe summarize with n().