0
0
R Programmingprogramming~15 mins

Row and column indexing in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Row and column indexing
📖 Scenario: You work in a small shop and keep track of daily sales in a table. You want to learn how to find specific sales data by looking at rows and columns.
🎯 Goal: Learn how to select specific rows and columns from a data frame in R using row and column indexing.
📋 What You'll Learn
Create a data frame called sales with exact values
Create a variable called day_index to select a specific row
Use row and column indexing to select the sales amount for that day
Print the selected sales amount
💡 Why This Matters
🌍 Real World
Selecting specific rows and columns from tables is common when working with sales data, customer data, or any spreadsheet-like information.
💼 Career
Data analysts and scientists often need to extract specific data points from large tables using row and column indexing.
Progress0 / 4 steps
1
Create the sales data frame
Create a data frame called sales with these exact columns and rows:
Day: "Monday", "Tuesday", "Wednesday"
Sales: 150, 200, 175
R Programming
Need a hint?

Use data.frame() with named vectors for columns.

2
Set the day index
Create a variable called day_index and set it to 2 to select the second row (Tuesday).
R Programming
Need a hint?

Just assign the number 2 to day_index.

3
Select the sales amount for the day
Use row and column indexing with sales and day_index to select the sales amount for that day. Store it in a variable called selected_sales. Use sales[day_index, 2] to get the sales column value.
R Programming
Need a hint?

Use sales[row, column] format to get the value.

4
Print the selected sales amount
Print the value stored in selected_sales using print().
R Programming
Need a hint?

Use print(selected_sales) to show the value.