Add proportions by group
add_proportion( x, y, ..., name = "p", percent_format = FALSE, percent_accuracy = 0.01 )
x | A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). |
---|---|
y | Variable to calculate proportions from. |
... | < |
name | The name of the new column in the output. If omitted, it will default to |
percent_format | A logical. If |
percent_accuracy | A numeric. If |
An object of the same type as x
. The output has the same groups as the input.
#> # A tibble: 3 x 3 #> cyl n p #> <dbl> <int> <dbl> #> 1 4 11 0.344 #> 2 6 7 0.219 #> 3 8 14 0.438