Calculate group sizes.

group_size(x)

n_groups(x)

Arguments

x

a grouped tbl

See also

Examples

if (require("nycflights13")) { by_day <- flights %>% group_by(year, month, day) n_groups(by_day) group_size(by_day) by_dest <- flights %>% group_by(dest) n_groups(by_dest) group_size(by_dest) }
#> [1] 254 265 439 8 17215 2439 275 443 375 297 6333 15508 #> [13] 896 2589 4681 371 1781 36 116 864 52 2884 4573 14064 #> [25] 3524 138 3941 1525 9705 7266 8738 569 9384 213 17 12055 #> [37] 765 1606 849 15 707 2115 5700 7198 110 2077 25 2720 #> [49] 5997 16174 1 1 668 2008 14082 4113 1789 1009 11728 2802 #> [61] 572 7185 3799 15 221 59 312 346 849 17283 1536 6554 #> [73] 1354 1632 4656 2875 365 19 376 2352 8163 2454 2416 3537 #> [85] 2737 686 804 10 1157 3923 13331 329 5819 2467 284 825 #> [97] 1211 4339 522 1761 7466 315 101 631 1036