prop_table_by_and_all | R Documentation |
Create a simple relative frequency table with percentages.
prop_table_by_and_all(
df,
dep,
by_var,
weights = NULL,
na.rm = TRUE,
round_perc = 1
)
df |
A |
dep |
The name of the dependent variable in the |
by_var |
The name of the group variable in the |
weights |
The name of the weights variable in the |
na.rm |
Set to |
round_perc |
With how many decimals should the percentages be given? |
Function is meant to be able to easily rbind
various tables.
Returns a data.frame with 1 row.
# without weights
prop_table_by_and_all(df = mtcars, dep = "cyl", by_var = "gear")
# with weights
mtcars2 <- mtcars
mtcars2[, "weights"] <- rep(c(0.5, 1), 16)
prop_table_by_and_all(df = mtcars2, dep = "cyl", by_var = "gear", weights = "weights")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.