table2 | R Documentation |
Returns a data frame table with both counts and percents.
table2(x, prop = F, include_NA = T, sort_descending = T)
x |
(a vector) A vector. |
prop |
(lgl) Whether to return proportions instead of percents. |
include_NA |
(lgl) Whether to count NA values. |
sort |
(lgl) Whether to sort by descending order. If null, sorts by group factor levels. |
A data frame (tbl).
#table and sort descending
sample(letters[1:10], size = 100, replace = T) %>% table2()
#ascending
sample(letters[1:10], size = 100, replace = T) %>% table2(sort_descending = F)
#using factor levels
sample(letters[1:10], size = 100, replace = T) %>% table2(sort_descending = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.