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

Andreas Borg andreas.borg at unimedizin-mainz.de
Fri Mar 11 16:22:27 CET 2011


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.



More information about the R-devel mailing list