BaşlayınÜcretsiz Başlayın

Using the stop() function

The stop() function is used to indicate that something is wrong.

Bu egzersiz

Defensive R Programming

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Stop the execution if ages are negative
mean_age <- function(ages) {
   if(any(ages < ___)) {
    ___("You have negative ages!")
  }
  
  m <- mean(ages)
  return(m)
}
Kodu Düzenle ve Çalıştır