Description Usage Arguments Value Examples
Takes in a character, integer or factor vector and tabulates the number of times each element appears.
1 |
x |
A character, integer or factor vector. NAs are allowed. |
sort |
TRUE if the result names should be sorted alphanumerically. |
A integer vector of counts of each element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | x <- factor(sample(1e5, 1e8, replace=T))
microbenchmark(table(x), tablec(x), times=3)
Unit: milliseconds
expr min lq mean median uq max
table(x) 9777.6457 10479.0949 10717.3382 11180.544 11187.1844 11193.8246
tablec(x) 678.0364 685.9467 713.1181 693.857 730.6589 767.4608
x <- sample(letters, 1e8, replace=T)
microbenchmark(table(x), tablec(x), tablec(x,sort=T), times=3)
Unit: seconds
expr min lq mean median uq max
table(x) 5.778514 5.829125 5.855560 5.879737 5.894083 5.908430
tablec(x) 1.589360 1.589381 1.589516 1.589402 1.589594 1.589786
tablec(x, sort = T) 1.589386 1.590520 1.591824 1.591655 1.593044 1.594432
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.