On 10.03.2016 16:48, Daniel Nüst wrote:
Hi Glenn!

On 10/03/16 15:05, Glenn Schultz wrote:
I have a package with to S4 classes (MBSCashFlow, REMICCashFlow and
BondCashFlow) all of which contain the slot Duration.  I would like
have an accessor Duration that would work on multiple signatures.  Is
this possible?  I have checked my books, help, BioConductor tutorials
and it appears that this is not possible.  Has anyone ever run into
this situation?

I actually use a similar mechanism to extract values from different S4
classes in my package, and it works quite well. So if I understand you
right, the following code might help you to get closer to want you want:

https://github.com/52North/sos4R/blob/master/R/SOS-methods-accessor.R

I created methods for different signatures, see for example
"sosObservedProperties".

Yes, that's straightforward. But I still wonder if it is at all possible to use not only different *signatures*, but also different argument *names* in S4, e.g.:

foo(formula, data, ...)

foo(data, grouping, ...)


Now I'm using a combination of S3 and S4 in my package for this purpose, and for some other quirks.

Thomas


--
Dr. Thomas Petzoldt
Technische Universitaet Dresden
Faculty of Environmental Sciences
Institute of Hydrobiology
01062 Dresden, Germany

E-Mail: thomas.petzo...@tu-dresden.de
http://tu-dresden.de/Members/thomas.petzoldt

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to