Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

DataCamp

Introduction to Writing Functions in R

via DataCamp

Overview

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

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.

Syllabus

  • 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.
  • 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.
  • 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.
  • Case Study on Grain Yields
    • Apply your function writing skills to a case study involving data preparation, visualization, and modeling.

Taught by

Richie Cotton

Reviews

4.7 rating at DataCamp based on 30 ratings

Start your review of Introduction to Writing Functions in R

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.