What is the problem with: the condition has length > 1 and only the first element will be used?
The reason you receive a warning is that Age is a vector, but you are comparing it with a scalar. R automatically takes the first element of Age. You can use "ifelse" and convert the class if needed.

If you want to limit yourself to base R, you can use the following:

age &lt;- function(Age){
    sapply(Age, function(x) if(x &lt; 15) "under 15" else if (x &lt;= 50) "15 to 50" else "over 50")
}