Bar plots with geom_bar and geom_col in R
📖 Scenario: You are working with a small store's sales data. You want to visualize how many items were sold for each product category using bar plots.
🎯 Goal: Create a bar plot using geom_bar and another bar plot using geom_col in R with ggplot2 to show the number of items sold per product category.
📋 What You'll Learn
Create a data frame called
sales_data with columns category and items_sold with exact valuesCreate a variable called
bar_plot_geom_bar that uses ggplot with geom_bar(stat = "count") to plot counts of categoriesCreate a variable called
bar_plot_geom_col that uses ggplot with geom_col() to plot items_sold per categoryPrint both plots using
print()💡 Why This Matters
🌍 Real World
Bar plots are commonly used in business to quickly see how different categories compare in counts or values, such as sales per product type.
💼 Career
Data analysts and data scientists use bar plots to communicate insights clearly to teams and stakeholders.
Progress0 / 4 steps