0
0
R Programmingprogramming~30 mins

Summary statistics in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Summary statistics
📖 Scenario: You work as a data analyst for a small company. You have collected sales data for a week and want to understand the basic statistics like average sales, minimum, and maximum sales to help the team make decisions.
🎯 Goal: Build a simple R script that calculates summary statistics (mean, minimum, maximum) for daily sales data.
📋 What You'll Learn
Create a numeric vector with exact daily sales values
Create a variable to hold the number of days
Calculate mean, minimum, and maximum sales using built-in functions
Print the calculated summary statistics
💡 Why This Matters
🌍 Real World
Summary statistics help businesses quickly understand data like sales, customer visits, or production numbers.
💼 Career
Data analysts and scientists use summary statistics daily to describe data before deeper analysis.
Progress0 / 4 steps
1
Create the sales data vector
Create a numeric vector called sales with these exact daily sales values: 150, 200, 170, 220, 180, 210, 190.
R Programming
Need a hint?

Use the c() function to combine numbers into a vector.

2
Create a variable for the number of days
Create a variable called num_days that stores the length of the sales vector using the length() function.
R Programming
Need a hint?

The length() function returns how many elements are in a vector.

3
Calculate summary statistics
Calculate the mean of sales and store it in avg_sales. Calculate the minimum and maximum sales and store them in min_sales and max_sales respectively. Use the functions mean(), min(), and max().
R Programming
Need a hint?

Use mean(), min(), and max() functions on the sales vector.

4
Print the summary statistics
Print the variables avg_sales, min_sales, and max_sales each on a new line using the print() function.
R Programming
Need a hint?

Use print() to show each statistic on its own line.