countpct | R Documentation |
Provided two columns, create a new column representing a number and percentage
countpct(.data, n, perc, name = "N", accuracy = 0.01, remove = TRUE)
.data |
A tbl. |
n |
Column of values. |
perc |
Column of percentages (as decimals). |
name |
Name of new column. |
accuracy |
Number to round to, NULL for automatic guess. |
remove |
If TRUE, remove input columns from output data frame. |
iris %>%
dplyr::group_by(Species) %>%
dplyr::summarise(n = dplyr::n()) %>%
dplyr::ungroup() %>%
dplyr::mutate(freq = prop.table(n)) %>%
countpct(n, freq)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.