Skip to content
KnowledgeCity

R Programming Intermediate: Object Oriented Programming

Learn how to create classes of objects for use in R code
Preview the first lesson free — get full access to all 8 lessons.
Course: On-Demand
Intermediate Provider Tom Rosenwinkel  8 Lessons ·  53m  in English 

Course Description

How can you create custom objects in R code? How do you bind attributes or methods to objects in R? The R programming language provides several different types of classes, each with their own answers to these questions. These include S3 classes, R6 classes, and S4 classes. Learning functional object-oriented concepts in general is essential to understanding the correct class structures to apply to create the custom objects needed for your R projects. The topics discussed in these lessons will build on your understanding of functional programming in R and provide a foundation for writing object-oriented code in R.

In these lessons on object-oriented programming, you will learn functional object-oriented programming in R. We will explore S3 classes, R6 classes, and S4 classes. By the end of these lessons, you will be able to create classes from any of these types that can be used in your own R projects or available for others to use.

What You'll Learn

  • Describe the basic object-oriented concepts implemented in S3 class structures, including S3 methods and inheritance
  • Explain how to bind attributes and methods in R6 classes, including private and active fields
  • Explore best practices for creating S4 classes and controlling access to slots
  • Apply S4 class methods and method dispatch in R
  • Use the Sloop package to support functional object-oriented programming in R
  • Create custom classes from S3, R6, and S4 types for use in your own R projects or by others

Key Takeaways

  • R provides several types of classes for object-oriented programming, including S3, R6, and S4 classes.
  • Learning functional object-oriented concepts helps you apply the correct class structures when creating custom objects in R.
  • These lessons build on functional programming in R and provide a foundation for writing object-oriented code.
  • By the end of the lessons, you can create classes from S3, R6, or S4 types for your own projects or for others to use.
  • The course covers binding attributes and methods to objects and controlling access to slots in S4 classes.

Frequently Asked Questions

What does this course cover?

It covers functional object-oriented programming in R, exploring S3 classes, R6 classes, and S4 classes, including topics such as the Sloop package, S3 methods and inheritance, R6 methods and references, R6 private and active fields, and S4 class methods and dispatch.

What will I be able to do after completing these lessons?

You will be able to create classes from S3, R6, or S4 types that can be used in your own R projects or made available for others to use.

Is there any recommended background for this course?

The lessons build on your understanding of functional programming in R, which provides a foundation for writing object-oriented code in R.

What skills does this course focus on?

It focuses on Object-Oriented Programming (OOP), creating custom components, and data binding in R.

Which R class types are explained in this course?

The course explains S3 classes, R6 classes, and S4 classes, each with their own approach to creating custom objects and binding attributes or methods.