According to R Documentation:
Conditional Element Selection
ifelse returns a value with the same shape as a test which is filled with elements selected from either yes or no depending on whether the element of the test is TRUE or FALSE.
ifelse(test, yes, no)
an object which can be coerced to logical mode.
return values for true elements of the test.
return values for false elements of the test.
- Since you are passing test values of length 1, you are getting results of length 1. If you pass longer test vectors, you will get longer results.
ifelse(c(TRUE, FALSE), c(3,4), c(5, 6))
 3 6
So ifelse is only used for the purpose of testing a vector of booleans and returning a vector of the same length, filled with elements taken from the vector’s yes and no arguments.