pie_bake | R Documentation |
This function allows you to create cool pie charts easily by providing just
the data and a template among the available ones. Moreover, you can choose whether
to display percentages or not and also optionally specify a title for the chart
and a name for the categories.
Using this function you can create the classical pie charts (including the donut charts).
If you are looking for something more complex and extravagant (but probably less
understandable), check out the pie_bake_pro
function.
pie_bake(data, template, perc = FALSE, group_name = "group", title = "")
data |
A data frame (or a tibble) with two variables (columns):
Please note that the labels are automatically sorted in alphabetical order.
If you want to specify a particular order, it is recommended to type numbers or
letters before the category names (e.g. "a. category1", "b. category2", ...). |
template |
The chosen template. |
perc |
A logical value. Should the proportions be displayed? |
group_name |
A string. If you want, you can specify a name for the categories. |
title |
A string. If you want, you can specify the title of the graph. |
A ggplot object. In particular, this function returns a pie (or donut) chart according to the data, the choice of template, and the other specifications provided.
See all the available templates displayed here!
example <- data.frame(
c("a. This", "b. Is", "c. Just", "d. An", "e. Example"),
c(2.9, 6.9, 4.20, 13.12, 6.66)
)
pie_bake(
data = example,
template = "basic3",
perc = TRUE,
group_name = "groups",
title = "Example1"
)
pie_bake(
data = example,
template = "red1",
title = "Ex2"
)
pie_bake(
data = example,
template = "donut2",
perc = TRUE,
group_name = "CAT:"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.