0
0
R Programmingprogramming~30 mins

Pipe chaining operations in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Pipe chaining operations
📖 Scenario: You work in a small bakery and keep track of daily sales in a list. You want to find out which items sold more than 10 units and then get their names in uppercase to display on a special board.
🎯 Goal: Use pipe chaining operations to filter items with sales greater than 10 and convert their names to uppercase.
📋 What You'll Learn
Create a named vector called sales with exact entries: Bread = 15, Cookies = 8, Cake = 12, Pie = 5
Create a variable called threshold and set it to 10
Use pipe chaining with %>% to filter sales for items with sales greater than threshold and then convert the item names to uppercase
Print the final result
💡 Why This Matters
🌍 Real World
Filtering and transforming sales data helps businesses quickly identify top-selling products and display them clearly for customers or staff.
💼 Career
Data analysts and business intelligence professionals often use pipe chaining in R to write clean, readable code for data filtering and transformation.
Progress0 / 4 steps
1
Create the sales data
Create a named vector called sales with these exact entries: Bread = 15, Cookies = 8, Cake = 12, Pie = 5
R Programming
Need a hint?

Use c() to create a named vector with names and values separated by =.

2
Set the sales threshold
Create a variable called threshold and set it to 10
R Programming
Need a hint?

Just assign the number 10 to the variable threshold.

3
Filter and transform with pipe chaining
Use pipe chaining with %>% to filter sales for items with sales greater than threshold and then convert the item names to uppercase. Store the result in a variable called top_items. Use magrittr::extract() or base R to filter and names() with toupper() to convert names.
R Programming
Need a hint?

Use %>% to chain filtering and renaming. Filtering keeps sales above threshold. Then change names to uppercase with toupper().

4
Print the final result
Write print(top_items) to display the filtered and renamed sales vector.
R Programming
Need a hint?

Use print(top_items) to show the final filtered and renamed vector.