# 1. Install and Load the 'dplyr' package
# This package contains the group_by, summarise, and pipe (%>%) tools
if (!require(dplyr)) install.packages("dplyr")
library(dplyr)

# 2. Create the Sample Data Frame (from the slide)
data <- data.frame(
  Category = c("A", "A", "B", "B", "C", "C"),
  Value = c(10, 15, 20, 25, 30, 35)
)

# 3. Group the data by Category
# The slide shows this step: it prepares the data to be calculated in groups
grouped_data <- data %>%
  group_by(Category)

# 4. Summarise the data (The 'Aggregation' step)
# This was mentioned in the text but missing from the code on screen.
# It calculates the Total and Average for each category (A, B, C).
summary_table <- grouped_data %>%
  summarise(
    Total_Value = sum(Value),
    Average_Value = mean(Value)
  )

# 5. View the final result
print("Here is your aggregated summary:")
print(summary_table)