[R-pkg-devel] Object getter, Am I doing this right?

Glenn Schultz glennmschultz at me.com
Thu May 12 17:14:38 CEST 2016


I am creating getters and setters for my package which uses S4.  To research getters and setters, I have been looking at the bio conductor website and documentation provided therein.  I came up with the below as a getter for the object PassThrough.  This works PrepaidPrin(PassThrough).  

The passthrough object has 50 slots and I have on the order of about 35 new classes.  Some of which are subclasses as well.  Thus, PrepaidPrin is also a slot in another class ScenarioTotalReturn.  So, I need multiple dispatch but I am still research that.  Before I started down this road I thought I would solicit opinions as to what I propose to make sure I have the basics correct.


 #' A standard generic function to access the slot PrepaidPrin
 #' @param object an object whose method signature is PassThrough
 #' @export
 setGeneric("PrepaidPrin", function(object)

 #' Method to extract Prepaid Principal from class PassThrough
 #' @param object the name of the object of type PassThrough
 #' @exportMethod PrepaidPrin
 setMethod("PrepaidPrin", signature("PassThrough"),
           function(object){object at PrepaidPrin})

More information about the R-package-devel mailing list