The two functions ifelse() and switch() execute flow control within a function or script. The function ifelse() evaluates a logical expression and chooses one of two values based on the result. The function switch() takes a value as an argument and returns another value based on the value of the first argument.
The Function ifelse( )
The ifelse() function takes three arguments. The first is a logical object or any object that can be coerced to logical, such as objects of the atomic modes or objects of mode list where there is only one level of depth to the list ...