Why advanced features enable complex work
📖 Scenario: Imagine you are a data analyst working with a list of sales numbers. You want to understand which sales are above a certain target and calculate some statistics. Using R's advanced features like vectorized operations and functions can help you do this quickly and clearly.
🎯 Goal: You will create a vector of sales numbers, set a target value, use R's vectorized features to find sales above the target, and then print the count of those sales.
📋 What You'll Learn
Create a numeric vector called
sales with these exact values: 120, 85, 90, 150, 200, 75Create a numeric variable called
target and set it to 100Use R's vectorized comparison to create a logical vector
above_target that is TRUE where sales are greater than targetPrint the number of sales above the target using
sum(above_target)💡 Why This Matters
🌍 Real World
Data analysts often need to quickly find and summarize data points that meet certain conditions, like sales above a target.
💼 Career
Using vectorized operations and logical indexing in R is a key skill for data scientists and analysts to write efficient and readable code.
Progress0 / 4 steps