Functions in R

In this second lesson of our interactive control flow, iteration, and functions course, you'll learn about functions and functional programming in R.

Specifically, we'll break down the components of a function. Then, you'll start working with and writing your own R functions as you practice using and build understanding of things like default arguments, how to use multiple inputs with an R function, how to use nested functions, and more.

You'll also learn to build your own custom functions in R, which can make coding and data processing tasks significantly more efficient and prevent you from writing the same code over and over again.

After you finish this lesson, you will be comfortable with functions and functional programming in R, and you'll be able to write your own functions.


  • Learn about functions in R.
  • Practice more complex uses like multiple inputs and nested functions.
  • Learn to write your own custom R functions.

Mission Outline

  1. Introduction
  2. Components of a Function
  3. Namespaces for Functions
  4. Using Multiple Inputs
  5. Default Arguments
  6. Handling Variable Numbers of Arguments
  7. Nested Functions
  8. Next Steps

Course Info:


This course requires a Basic subscription and includes three missions and one guided project.  It is the third course in the Data Analyst in R learning path.


Take a Look Inside