r-oop

Guide R developers in selecting and implementing S7, S3, S4, and vctrs OOP systems.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/jhelvy/dotfiles --skill r-oop-jhelvy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r-oop
Source: https://github.com/jhelvy/dotfiles/tree/main/claude/skills/r-oop
Command: npx skills add https://github.com/jhelvy/dotfiles --skill r-oop-jhelvy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps R developers choose and effectively use the appropriate object-oriented programming (OOP) system (S7, S3, S4, vctrs) for their specific project needs, leading to more robust and maintainable code.

Core Features & Use Cases

  • OOP System Guidance: Provides a decision tree and comparison matrix to select between S7, S3, S4, and vctrs.
  • Code Examples: Demonstrates practical implementation of classes and methods in S7, S3, and vctrs.
  • Migration Strategies: Offers advice on migrating from older OOP systems to S7.
  • Use Case: You are starting a new R package and need to decide whether to use S7 for its formal classes and validation, or if a simpler S3 approach is sufficient. This Skill will guide your decision.

Quick Start

Use the r-oop skill to understand when to choose S7 over S3 for new R projects.

Frequently Asked Questions about r-oop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between S7, S3, S4, and vctrs for object-oriented programming in R?

To choose an R OOP system, evaluate your project needs: S3 offers simplicity, S4 provides formal definitions, vctrs builds custom vectors, and S7 delivers modern validation. A decision tree and comparison matrix help map your specific requirements to the appropriate system.

What is the best way to implement classes and method dispatch in S7?

Implementing S7 classes involves defining formal classes and methods with built-in validation. Practical code examples demonstrate how to structure class design, handle method dispatch, and manage inheritance to ensure robust and maintainable R package development.

When should I use S3 instead of vctrs for building R packages?

Use S3 for lightweight, flexible object-oriented programming when simplicity is prioritized, whereas vctrs is designed specifically for constructing custom vector types with consistent behavior. Evaluating package scalability requirements dictates the correct choice.

How do I migrate from S4 or S3 OOP systems to S7 in R?

Migrating to S7 involves adopting its formal class definitions and validation mechanisms while replacing older S3 or S4 structures. The skill provides specific migration strategies and practical examples to transition existing codebases safely.

Does S7 support inheritance and method dispatch for scalable R applications?

S7 fully supports inheritance and method dispatch, providing a formal framework for scalable R applications. It enables developers to build maintainable object hierarchies and cleanly manage method resolution across complex package architectures.