r-oop
R object-oriented programming guide for S7, S3, S4, and vctrs. Use when designing R classes or choosing an OOP system.
npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill r-oop --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# R Object-Oriented Programming *S7, S3, S4, and vctrs: choosing the right OOP system for your needs* ## S7: Modern OOP for New Projects - **S7 combines S3 simplicity with S4 structure** - **Formal class definitions with automatic validation** - **Compatible with existing S3 code** ```r # S7 class definition Range <- new_class("Range", properties = list( start = class_double, end = class_double ), validator = function(self) { if (self@end < self@start) { "@end must be >= @start" } } ) # Usage - constructor and property access x <- Range(start = 1, end = 10) x@start # 1 x@end <- 20 # automatic validation # Methods inside <- new_generic("inside", "x") method(inside, Range) <- function(x, y) { y >= x@start & y <= x@end } ``` ## OOP System Decision Matrix ### S7 vs vctrs vs S3/S4 Decision Tree **Start here:** What are you building? ### 1. Vector-like objects (things that behave like atomic vectors) ``` Use vctrs when: - Need data frame integration (columns/rows) - Want type-stable vector operations - Building factor-like, date-like, or numeric-like classes - Need consistent coercion/casting behavior - Working with existing tidyverse infrastructure Examples: custom date classes, units,
- S7: Modern OOP for New Projects
- OOP System Decision Matrix
- S7 vs vctrs vs S3/S4 Decision Tree
- 1. Vector-like objects (things that behave like atomic vectors)
- 2. General objects (complex data structures, not vector-like)
- Detailed S7 vs S3 Comparison
- Practical Guidelines
- Choose S7 when you have
- Choose vctrs when you need
- Choose S3 when you have
- S3 Patterns
- Basic S3 Class
- S3 Inheritance
- S7 Patterns
What does the r-oop skill do?
R object-oriented programming guide for S7, S3, S4, and vctrs. Use when designing R classes or choosing an OOP system.
How do I install it?
Run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill r-oop --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From brycewang-stanford/Auto-Empirical-Research-Skills, a repository with 3,244 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.