Bar Plot
November 5, 2024
January 17, 2026
Sample Dataset
Exercises
Create a stacked bar plot of category by subgroup, showing how each subgroup contributes to the total count in each category.
Create a grouped bar plot of category by subgroup, so that each subgroup is displayed as separate bars within each category.
Create a bar plot of category with bars filled according to subgroup (e.g., “X” = red, “Y” = green).
Create a bar plot of category with subgroup fill, add labels to each bar, and rotate the x-axis labels to make them more readable.
Create a bar plot of category with bars ordered by frequency, showing the most frequent categories first.
Create a grouped bar plot of category by subgroup and set the width of the bars to 0.6.
Create a bar plot that bins the score variable into intervals (e.g., 50-60, 60-70, etc.) and displays the count for each interval.
Hint: Use the cut() function to create intervals and plot the counts of each interval.
Calculate the average score for each category and display it as a bar plot.
Hint: Use dplyr::group_by() and dplyr::summarize() to calculate the average score, then use geom_bar(stat = "identity") to plot the results.
Create a stacked bar plot showing the count of score intervals for each region.
Hint: Use cut() to bin score, then plot the counts for each region as stacked bars.