Summarise Data with group_by() in R
📖 Scenario: You have sales data from a small store. Each sale has a product name and the number of units sold. You want to find out how many units were sold for each product in total.
🎯 Goal: Build a small R script that groups sales by product and calculates the total units sold for each product using group_by() and summarise().
📋 What You'll Learn
Create a data frame called
sales with columns product and units with exact valuesCreate a grouped data frame using
group_by() on productUse
summarise() to calculate total units sold per productPrint the summarised data frame
💡 Why This Matters
🌍 Real World
Stores and businesses often need to summarise sales data by product to understand which items sell the most.
💼 Career
Data analysts and scientists use <code>dplyr</code> functions like <code>group_by()</code> and <code>summarise()</code> to prepare and analyse data efficiently.
Progress0 / 4 steps