What is supposed to happen when you compare a number with an empty value? Should the condition x > y evaluate to TRUE or FALSE, or should there be a different effect? One way to handle the situation is like this:
if (length(y) == 0) {
cat("y is numeric(0)")
} else {
if (x > y) {
cat("x is greater than y")
} else {
cat("x is less than or equal y")
}
}