Skip to main content
HomeR

Course

Introduction to Writing Functions in R

BasicSkill Level
4.7+
589 reviews
Updated 08/2024
Take your R skills up a notch by learning to write efficient, reusable functions.
Start Course for Free
RProgramming4 hr14 videos52 Exercises4,350 XP52,645Statement of Accomplishment

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Loved by learners at thousands of companies

Group

Training 2 or more people?

Try DataCamp for Business

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.

Prerequisites

Introduction to the TidyverseIntermediate R
1

How to Write a Function

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

All About Arguments

3

Return Values and Scope

4

Case Study on Grain Yields

Introduction to Writing Functions in R
Course
Complete

Earn Statement of Accomplishment

Add this credential to your LinkedIn profile, resume, or CV
Share it on social media and in your performance review
Enroll Now

Don’t just take our word for it

*4.7
from 589 reviews
75%
23%
1%
0%
1%
  • Nestor
    16 hours ago

  • ‪IBRAHIM
    22 hours ago

  • Delruba Mahmud
    3 days ago

  • Napaporn
    last week

  • Firdausi
    last week

  • Jeff
    2 weeks ago

Nestor

Delruba Mahmud

Napaporn

FAQs

What will I gain from learning to write my own R functions?

Writing your own functions makes analyses more readable, reduces errors, and increases reusability across projects. It is considered the single biggest productivity boost for R programmers.

What real-world datasets are used in the exercises?

You will work with data on Wyoming tourism, stock price-to-earnings ratios, and grain yields to practice writing practical data science functions in realistic contexts.

Does the course explain how R handles variable scope?

Yes. Chapter 3 covers how R decides which variables exist and are accessible, including return values, early returns, and returning multiple values from a function.

What R prerequisites do I need?

You should have completed Introduction to R, Intermediate R, and Introduction to the Tidyverse. Comfort with vectors, data frames, and dplyr pipelines is expected.

Is there a capstone project in this course?

Yes. The final chapter is a case study on grain yields where you apply your function writing skills to data preparation, visualization, and modeling tasks.

Join over 19 million learners and start Introduction to Writing Functions in R today!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Grow your data skills with DataCamp for Mobile

Make progress on the go with our mobile courses and daily 5-minute coding challenges.