Re: [Rd] Using missing() in a S4 method with extra arguments

From: Andreas Borg <andreas.borg_at_unimedizin-mainz.de>
Date: Fri, 11 Mar 2011 16:22:27 +0100

Hi Martin,

in the real function, I am not dispatching on the argument for which I test missingness, but it might be a good idea to do so - this way I could make the function tidier by relocating different branches to seperate methods. Thanks for the suggestion!

Andreas

> if you're testing for the missing-ness of y, and y is in the function
> signature, then use that for dispatch
>
> setMethod(fun, c("character", "missing"),
> function(x=0, y=0, z=0, ...) "missing")
> setMethod(fun, c("character", "ANY"),
> function(x=0, y=0, z=0, ...) "not missing")
>
> Since you're dispatching on x and y, it doesn't really make sense (to me
> ;) to assign default values to them. Testing for missing-ness of z would
> I think have to rely on NA / NULL or other sentinel.
>
> Martin
>

-- 
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: borg_at_imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 11 Mar 2011 - 15:23:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Mar 2011 - 18:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive