ggQC is an R package for creating quality-control charts with ggplot2. Its Pareto-chart functionality combines bars for category counts with a cumulative-percentage line on a secondary axis. section 15.4.1
A practical ggQC workflow includes:
- Prepare the data with dplyr before passing it to ggplot(). section 15.4.1
- Use stat_pareto() to add the cumulative-percentage line automatically. section 15.4.1
- Sequence categories before plotting so the x-axis labels appear correctly. section 15.4.1
NBA franchise games
Filter out child records to retain 47 past and present franchises, then group by franchise and plot games played. The resulting Pareto chart compares each franchise’s games with the cumulative share across all franchises. section 15.4.1
df4 %>%
group_by(franchise) %>%
summarize(games) %>%
ggplot(aes(x = franchise, y = games)) +
theme(axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5)) +
stat_pareto() +
ggtitle("Pareto Chart: Games Played (1946-2020)") +
xlab("") +
ylab("Games Played") +
theme(plot.title = element_text(face = "bold"))
Inspect the complete ggplot2 pipeline using stat_pareto(), rotated franchise labels, and a descriptive title. section 15.4.1
