[R] Method dispatch for print() in package its
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 12 17:19:46 CEST 2007
Setting S4 methods for print() works correctly, as in your examples.
Your first example does not call print(), so it is not suprising that no
method dispatch takes place.
You seem to suppose that such a method should be used for top-level
auto-printing, and it will not be as your example shows. Auto-printing
calls show() on S4 objects, and in this case show() is handling the object
by its default method.
Note that if there is no S4 print method set, print(x) on an S4 object 'x'
will in fact call show(x). So had an S4 show() method been set, all three
examples would have given the same output (via show()).
On Thu, 12 Apr 2007, Albrecht, Dr. Stefan (AZ Private Equity Partner) wrote:
> Dear all,
>
> in the package its the print() method does not seem to correctly work in all circumstances:
>
>
>> selectMethod(print, "its")
> Method Definition:
>
> function (x, ...)
> {
> print(x at .Data <mailto:x at .Data> , ...)
(sic!)
> }
> <environment: namespace:its>
>
> Signatures:
> x
> target "its"
> defined "its"
>
>
>
>> fundPME.lst[[1]]$irr
> An object of class "its"
> IRR HSBC MEEM
> 2005-10-31 0.1926175 0.07802736
> Slot "dates":
> [1] "2005-10-31 Westeuropäische Normalzeit"
>
>
>> fundPME.lst[[1]]$irr at .Data
> IRR HSBC MEEM
> 2005-10-31 0.1926175 0.07802736
>
>
>> print(fundPME.lst[[1]]$irr)
> IRR HSBC MEEM
> 2005-10-31 0.1926175 0.07802736
>
>
> So, is it necessary to define a print.its S3 method, or what should we do?
>
> Many thanks and best regards,
> Stefan
>
> ____________________________________
> Dr. Stefan Albrecht, CFA
> Allianz Private Equity Partners GmbH
> Königinstr. 19 | 80539 Munich | Germany
>
> Phone: +49.(0)89.3800.18317
> Fax: +49.(0)89.3800.818317
> EMail: stefan.albrecht at allianz.com <mailto:stefan.albrecht at allianz.com>
> Web: www.apep.com <http://www.apep.com/>
>
>
> Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl Ralf Jung
> Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | Ust-ID-Nr.: DE 813 264 786
>
>
>
> [[alternative HTML version deleted]]
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list