If this, Else that
An extension of the if statement is to perform a different action if the condition is false. You can do this by adding else
after your if
statement:
if(condition) {
code if true
} else {
code if false
}
This exercise is part of the course
Intermediate R for Finance
Exercise instructions
- Extend the last exercise by adding an
else
statement that prints"Do nothing!"
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
micr <- 57.44
# Fill in the blanks
if( micr < 55 ) {
print("Buy!")
} ___ {
___
}