Aan de slagGa gratis aan de slag

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 
}

Deze oefening maakt deel uit van de cursus

Intermediate R for Finance

Cursus bekijken

Oefeninstructies

  • Extend the last exercise by adding an else statement that prints "Do nothing!".

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

micr <- 57.44

# Fill in the blanks
if( micr < 55 ) {
    print("Buy!")
} ___ {
    ___
}
Code bewerken en uitvoeren