Working with Logical (Boolean) Type in R
📖 Scenario: You are analyzing survey data where participants answered yes or no questions. The answers are stored as logical values: TRUE for yes and FALSE for no.
🎯 Goal: You will create a logical vector representing answers, set a threshold for counting positive answers, count how many answers are TRUE, and then print the count.
📋 What You'll Learn
Create a logical vector called
answers with the exact values TRUE, FALSE, TRUE, TRUE, FALSECreate a variable called
threshold and set it to 2Use a variable called
true_count to count how many TRUE values are in answersPrint the value of
true_count💡 Why This Matters
🌍 Real World
Logical (boolean) values are used in surveys, decision making, and filtering data based on yes/no or true/false answers.
💼 Career
Understanding logical types helps in data analysis, programming conditions, and controlling program flow in many jobs like data science and software development.
Progress0 / 4 steps