9) Conditionals
📖 Conditional Statements
This week we introduce the notion of R expressions, and we provide the syntax used by R to handle if-else statements and related conditionals constructs.
📰 Slides
🎯 Objectives
At the end of this week you will be able to:
- Describe what curly braces
{...}are used for in R. - Write if-else statements to handle simple or multiple conditions
- Describe the purpose of the vectorized function
ifelse() - Describe and give an example of
switch() - Describe and give an example of the congruent vectors strategy (which is connected with the lookup-vector trick)
- Describe and give an example of the “dplyr” function
case_when()