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

Write your own function (2)

There are situations in which your function does not require an input. Let's say you want to write a function that gives us the random outcome of throwing a fair die:

throw_die <- function() {
  number <- sample(1:6, size = 1)
  number
}

throw_die()

Up to you to code a function that doesn't take any arguments!

Bu egzersiz

Intermediate R

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

Egzersiz talimatları

  • Define a function, hello(). It prints out "Hi there!" and returns TRUE. It has no arguments.
  • Call the function hello(), without specifying arguments of course.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Define the function hello()





# Call the function hello()
Kodu Düzenle ve Çalıştır