Using the stop() function
The stop()
function is used to indicate that something is wrong.
Este ejercicio forma parte del curso
Defensive R Programming
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
# Stop the execution if ages are negative
mean_age <- function(ages) {
if(any(ages < ___)) {
___("You have negative ages!")
}
m <- mean(ages)
return(m)
}