s4
When does it pay off to use S4 methods in R programming
My experience is in line with yours, so I use S3 exclusively. To clarify: S4 has some slick features (e.g. dispatch on multiple arguments and slot type-checking), but I have not encountered a situation where the features outweighed the costs. Examples of the costs include: any slot change requires a full object copy and (potentially … Read more
R: what are Slots?
Slots are linked to S4 objects. A slot can be seen as a part, element or a “property” of an object. Say you have a car object, then you can have the slots “price”, “number of doors”, “type of engine”, “mileage”. Internally, that is represented a list. An example : setClass(“Car”,representation=representation( price = “numeric”, numberDoors=”numeric”, … Read more
How to properly document S4 class slots using Roxygen2?
Updated answer for Roxygen2 5.0.1, current as of 6.0.1 For S4, the best practice now is documenting using the @slot tag: #’ The title for my S4 class that extends \code{“character”} class. #’ #’ Some details about this class and my plans for it in the body. #’ #’ @slot myslot1 A logical keeping track … Read more