Control Flow in R
In this first lesson of our interactive control flow, iteration, and functions course, we'll dive into how you can control what happens with your code by using conditionals.
Specifically, you'll learn about the if statement, the if_else() function, and the case_when() function in R. You'll write functions that control data processing based on conditions, and build complexity by using multiple conditions.
The ability to create these kinds of flows is critical in R programming. Mastering control flow gives you powerful tools for sorting and processing your data based on any condition or conditions you set.
After you finish this lesson, you will be comfortable with if statements, the if_else() and case_when() functions in R, and with building complex conditionals using more than one condition at a time.
- Review of Comparison Operators
- The if Statement
- The if_else() Function
- Moving Beyond Two Branches
- Using Multiple Conditions
- A Technical Note on Multiple Conditions
- The case_when() Function
- Other Useful Comparison Operators
- Next Steps