On Mar 10, 2010, at 5:43 AM, Achim Zeileis wrote:

On Wed, 10 Mar 2010, Christophe Genolini wrote:

Hi the list

I define a S3 function that can have a various number of argument using '...' When some arguments are missing, I would like to give them some default value:

func.numeric <- function(x,...){
if(missing(y)){y<-3}
}

But it does not works...

I precise that I can not put 'y' explicitly in the argument list since func is an S3 function, I cannot change its arguments.
Any suggestions?

If the generic func() has arguments "x" and "...", then you can easily define a method func.numeric(x, y, ...). Methods need to implement all arguments of a generic (including ...) but may add additional argument.


I am assuming that one could also use the default assignment to y in the argument list?

func.numeric(x, y=3, ...)

hth,
Z

Thanks
Christophe



David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to