Vector creation with c()
📖 Scenario: You are helping a small shop owner organize their daily sales data. They want to keep track of the number of items sold each day in a simple list.
🎯 Goal: Create a vector using the c() function in R to store the number of items sold each day for a week.
📋 What You'll Learn
Create a vector called
sales with the exact values: 5, 8, 6, 7, 9, 4, 10Create a variable called
days and set it to 7Use a
for loop with variable i to iterate over the sales vectorCalculate the total sales in a variable called
total_salesPrint the total sales using
print(total_sales)💡 Why This Matters
🌍 Real World
Tracking daily sales helps shop owners understand their business performance and plan better.
💼 Career
Data analysts and business managers often work with vectors and loops to process and summarize data.
Progress0 / 4 steps