Description Usage Value Examples
count_pct
is the extenstion of dplyr::count with percent
count_pct_group
is the extenstion of dplyr::count with percent by group
1 2 3 |
returns a dataframe with count and percentage columns
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(dacol, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(scales, warn.conflicts = FALSE)
df = data.frame(x = c(1, 2, 3, 4, 5),
y = c("b", "a", "k", "b", "k"),
z = c(5, 8, 8, 6, 5))
df %>% count_pct(y)
df %>% count_pct(z)
mtcars %>% count_pct(cyl)
mtcars %>% count_pct(cyl, sort = TRUE)
mtcars %>% count_pct(cyl, am, sort = TRUE)
mtcars %>% count_pct_group(cyl)
mtcars %>% count_pct_group(cyl, am)
mtcars %>% count_pct_group(cyl, am) %>% arrange(cyl, desc(n))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.