Interactive Course

Introduction to Function Writing in R

Take your R skills up a notch by learning to write efficient, reusable functions.

  • 4 hours
  • 14 Videos
  • 52 Exercises
  • 1,185 Participants
  • 4,350 XP

Loved by learners at thousands of top companies:

axa-grey.svg
lego-grey.svg
deloitte-grey.svg
airbnb-grey.svg
siemens-grey.svg
paypal-grey.svg

Course Description

Being able to write your own functions makes your analyses more readable, with fewer errors, and more reusable from project to project. Function writing will increase your productivity more than any other skill! In this course you'll learn the basics of function writing, focusing on the arguments going into the function and the return values. You'll be writing useful data science functions, and using real-world data on Wyoming tourism, stock price/earnings ratios, and grain yields.

  1. 1

    How to write a function

    Free

    Learn why writing your own functions is useful, how to convert a script into a function, and what order you should include the arguments.

  2. All about arguments

    Learn how to set defaults for arguments, how to pass arguments between functions, and how to check that users specified arguments correctly.

  3. Return values and scope

    Learn how to return early from a function, how to return multiple values, and understand how R decides which variables exist.

  4. Case study on grain yields

    Apply your function writing skills to a case study involving data preparation, visualization, and modeling.

What do other learners have to say?

Devon

“I've used other sites, but DataCamp's been the one that I've stuck with.”

Devon Edwards Joseph

Lloyd's Banking Group

Louis

“DataCamp is the top resource I recommend for learning data science.”

Louis Maiden

Harvard Business School

Ronbowers

“DataCamp is by far my favorite website to learn from.”

Ronald Bowers

Decision Science Analytics @ USAA

Richie Cotton
Richie Cotton

Head of Content Quality at DataCamp

Richie runs the Content Quality team at DataCamp. He has been using R since 2004, in the fields of proteomics, debt collection, and chemical health and safety. He has released almost 30 R packages on CRAN and Bioconductor – most famously the assertive suite of packages – as well as creating and contributing to many others. He also has written two books on R programming, Learning R and Testing R Code.

See More
Icon Icon Icon professional info