col_cal_percent | R Documentation |
create a new column which is the percentage of other columns
col_cal_percent(df, new_col_name, numerator_cols, denominator_cols)
df |
input data frame |
new_col_name |
new column name |
numerator_cols |
numerator columns |
denominator_cols |
denominator columns |
data frame with a new percentage column
test_df <- data.frame( hc1 = c(2, 0, 1, 5, 6, 7, 10), hc2 = c(1, 0, 10, 12, 4, 1, 9 ), total = c(10, 2, 0, 39, 23, 27, 30) ) dataMojo::col_cal_percent(test_df, new_col_name = "hc_percentage", numerator_cols = c("hc1", "hc2"), denominator_cols = "total" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.