Colombo
Colombo

Reputation: 609

Is there any advantage of RC over R6?

I have some experience with R6 classes. They are powerful, with a lot of great tools under the hood. The documentation is amazing, the interface is clean, and the created classes have just the amount of methods that one requires. The option to set methods and fields as private makes it possible.

I just checked Reference Classes, often shortened as just RC from the methods package. Their interface is similar, but feels more complex than R6. They appear to have a smaller number of features (no private fields/methods). By default, RC creates a huge amount of methods for the objects (checked by instance$<tab><tab> in the console).

For instance, RC classes won't initialize methods immediately, so they are not available when you type instance$<tab><tab> (but available for call), they create .->x for every field x in addition to rf$x, and they have general getter rf$field("x"). All this makes the interface quite busy when you have multiple fields.

R6 classes have a clone method. RC classes a copy method, but is not shown initially (only when you try to call it?), which makes the whole interface confusing.

On top of that, RC classes require much more memory compared to the R6 classes (according to R6 authors here).

Is there any advantage to the RC classes besides being included in base R?

Upvotes: 3

Views: 102

Answers (0)

Related Questions