0
0
R Programmingprogramming~30 mins

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

Choose your learning style9 modes available
Descriptive 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, maximum, and total sales.
🎯 Goal: Build a simple R script that calculates descriptive statistics (mean, min, max, sum) 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, maximum, and total sales using built-in R functions
Print the results clearly
💡 Why This Matters
🌍 Real World
Descriptive statistics help summarize and understand data quickly in many fields like business, healthcare, and research.
💼 Career
Data analysts and scientists use these basic statistics daily to report insights and make decisions.
Progress0 / 4 steps
1
Create the sales data vector
Create a numeric vector called daily_sales with these exact values: 150, 200, 170, 220, 180, 210, 190.
R Programming
Need a hint?

Use the c() function to create a vector with the given numbers.

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

Use length(daily_sales) to find how many days of sales data you have.

3
Calculate descriptive statistics
Calculate the mean, minimum, maximum, and total sales from daily_sales and store them in variables called avg_sales, min_sales, max_sales, and total_sales respectively. Use the functions mean(), min(), max(), and sum().
R Programming
Need a hint?

Use the built-in R functions to calculate each statistic and assign them to the correct variable names.

4
Print the descriptive statistics
Print the values of avg_sales, min_sales, max_sales, and total_sales each on a new line with descriptive text using the print() function.
R Programming
Need a hint?

Use print(paste("Text", variable)) to show descriptive text and the value on the same line.