Fast tabulate
ftabulate.RdCalculates the number of times each unique element occurs after excluding missing values.
A fast, generalized alternative to base::tabulate().
Details
base::tabulate() only counts positive integers.
ftabulate() will count any nonmissing element type.
Examples
#----------------------------------------------------------------------------
# ftabulate() example
#----------------------------------------------------------------------------
library(bkbase)
x <- sample(1:10, size = 100, replace = TRUE)
ftabulate(x)
#> [1] 17 10 13 9 10 12 12 5 7 5
tabulate(x)
#> [1] 12 10 17 5 5 13 12 9 7 10
table(x)
#> x
#> 1 2 3 4 5 6 7 8 9 10
#> 12 10 17 5 5 13 12 9 7 10