Description Usage Arguments Value Examples
make a group column for a tibble
1 |
data |
a tibble data set |
id_col |
the id column of the data set for grouping |
group_by_col |
the column used for grouping |
group_method |
the grouping methods include "category", "equal_interval", "equal_number", "cut_by_breaks", and "percent_rank", which utilize some functions provided by ggplot2 and dplyr. |
... |
Arguments passed on to different group_method. For the method "cut_by_breaks", breaks must be provided. The variable "labels" are commonly used by the "equal_interval", "equal_number", and "cut_by_breaks". |
A tibble containing id_col and group column.
1 2 3 4 5 6 7 8 9 | data = iris %>% mutate(id = str_c("id_", 1:nrow(.)))
gen_group(data = data, id_col = "id", group_by_col = "Species", group_method = "category")
gen_group(data = data, id_col = "id", group_by_col = "Sepal.Length",
group_method = "equal_interval", labels = c("low", "middle", "high"))
gen_group(data = data, id_col = "id", group_by_col = "Sepal.Length",
group_method = "equal_number", labels = c("low", "middle", "high"))
gen_group(data = data, id_col = "id", group_by_col = "Sepal.Length",
group_method = "cut_by_breaks", breaks = c(0, 5.1, 6.5, 100), labels = c("low", "middle", "high"))
gen_group(data = data, id_col = "id", group_by_col = "Sepal.Length", group_method = "percent_rank")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.