I've been trying to create an error message when the ouput entered is wrong, for example, in this code instead of entering 4 digits number, it is entered a character.
I keep receiving an error. Any tips?
get_age <- function() {
  yob <- readline("Please enter your year of birth: ")
  age <- 2022 - as.numeric(yob)
  return(age)
}
  if (get_age != as.numeric(yob)) { 
  withCallingHandlers(
    warning = function(cnd){
      readline("This is not a number. Please, try again.")
    },
    print("please, enter a numerical value"), 
return(get_age())
  )
}
