Skip to main content
HomeR

Course

Defensive R Programming

IntermediateSkill Level
4.9+
70 reviews
Updated 11/2024
Learn defensive programming in R to make your code more robust.
Start Course for Free
RProgramming4 hr16 videos51 Exercises3,400 XP5,020Statement 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

Writing R scripts is easy. Writing good R code is hard. In this course, we'll discuss defensive programming - a set of standard techniques that will help reduce bugs and aid working in teams. We examine techniques for avoiding common errors and also how to handle the inevitable error that arises in our code. The course will conclude looking at when to make the transition from script to project to package.

Prerequisites

Intermediate R
1

Avoiding Conflict

In this first chapter, you'll learn what defensive programming is, and how to use existing packages for increased efficiency. You will then learn to manage the packages loaded in your environment and the potential conflicts that may arise.
Start Chapter
2

Early warning systems

3

Preparing your defenses

4

Creating a Battle Plan

Creating a script is nice, but working on a project with several scripts and assets requires structure. This final chapter will teach you good organization practices, so you can go from script to package with an optimal workflow.
Start Chapter
Defensive R Programming
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.9
from 70 reviews
93%
6%
1%
0%
0%
  • alexandrina
    6 days ago

  • N144320004
    2 weeks ago

  • William
    4 weeks ago

  • Emese
    5 weeks ago

  • Zlatko
    last month

  • Stanislau
    2 months ago

alexandrina

N144320004

William

FAQs

What is defensive programming and why does it matter in R?

Defensive programming is a set of standard techniques to reduce bugs and improve team collaboration. It helps you write more reliable R code through consistent practices and proper error handling.

What specific topics does this course cover?

You learn package conflict management, using messages and warnings and errors effectively, R coding best practices, and when to transition from scripts to projects to packages.

Is this course for beginners or experienced R users?

It is beginner level, requiring only Introduction to R and Intermediate R. It is ideal for anyone who can write R scripts but wants to write more robust, production-quality code.

Does the course cover organizing R projects and packages?

Yes. Chapter 4 teaches good organizational practices for moving from a single script to a structured project with multiple files and eventually to an R package.

How long does this course take to complete?

It has 4 chapters with 51 exercises. The median completion time is about 1.2 hours, making it a quick course focused on practical programming habits.

Join over 19 million learners and start Defensive R Programming 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.