waffle
package and geom_waffle()
from
ggplot2 package. We will also cover some of the customization options
that are available.
Commodity Date Average Unit
1 Pomegranate 11-09-2013 210.0 Kg
2 Lemon 11-09-2013 32.5 Kg
3 Ginger 11-09-2013 145.0 Kg
waffle
packageinstall.packages("waffle", repos = "https://cinc.rud.is")
library(waffle)
library(dplyr)
df1 <- df %>% group_by(Commodity) %>% summarise(Count = n())
df1 %>% as.data.frame()
Commodity Count
1 Coriander Green 8
2 Ginger 8
3 Lemon 3
4 Mint 6
5 Pomegranate 8
6 Spinach Leaf 7
waffle(df1, rows = 5, legend_pos = "bottom")
colors <- c("#210578", "#b65ea8", "#dfb9c2", "#5a1d8d", "#ca89ac", "#923aa1")
waffle(df1, rows = 5, colors = colors, legend_pos = "bottom")
geom_waffle()
from ggplot2install.packages("ggplot2")
library(ggplot2)
ggplot(df1, aes(fill = Commodity, values = Count)) +
geom_waffle(n_rows = 5, size = 0.5, colour = "white", na.rm = T)
ggplot(df1, aes(fill = Commodity, values = Count)) +
geom_waffle(n_rows = 5, size = 2, colour = "white", na.rm = T) +
scale_fill_manual(name = NULL,
values = c("#210578", "#b65ea8", "#dfb9c2", "#5a1d8d", "#ca89ac", "#923aa1"),
labels = c(df1$Commodity)) +
coord_equal() +
theme_void() +
theme(legend.position = "bottom")
sum(df1$Count)
[1] 40