1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Writing Functions in R

Exercise

Your first function: tossing a coin

Time to write your first function! It's a really good idea when writing functions to start simple. You can always make a function more complicated later if it's really necessary, so let's not worry about arguments for now.

Instructions 1/4

undefined XP
    1
    2
    3
    4
  • Simulate a single coin toss by using sample() to sample from coin_sides once.