Skip to content

stats::median

2 messages · Rob Hyndman, Martin Maechler

#
The generic stats::median method is defined as
   median <- function (x, na.rm = FALSE)  {UseMethod("median")}

I suggest that this should become
   median <- function (x, na.rm = FALSE, ...)  {UseMethod("median")}

This would allow additional S3 methods to be developed with additional
arguments.

Currently I have to over-ride this generic definition in the
demography package because median.demogdata has several other
arguments.

This shouldn't break any code, and will make it easier for new S3
methods to be developed. It is also consistent with almost all other
S3 methods which do include an ellipsis.

-------------------------------------------------------------
Rob J Hyndman
Professor of Statistics, Monash University
www.robjhyndman.com
11 days later
#
> The generic stats::median method is defined as median <-
    > function (x, na.rm = FALSE) {UseMethod("median")}

    > I suggest that this should become median <- function (x,
    > na.rm = FALSE, ...)  {UseMethod("median")}

    > This would allow additional S3 methods to be developed
    > with additional arguments.

and  S4  methods, too.

    > Currently I have to over-ride this generic definition in
    > the demography package because median.demogdata has
    > several other arguments.

    > This shouldn't break any code, and will make it easier for
    > new S3 methods to be developed. It is also consistent with
    > almost all other S3 methods which do include an ellipsis.

"shouldn't break any code"   is almost always quite optimistic
	   nowadays,....

Actually it probably will break things when people start using
the new R version which implements the above *AND* use packages
installed with a previous version of R.
I agree that this does not count as "breaking any code".

In spite of all that  *and*
the perennial drawback that a '...' will allow argument name
typos to go unnoticed

I agree you have a good argument nowadays, that median() should
be the same as many similar "basic statistics" R functions and
so I'll commit such a change to R-devel (to become R 3.4.0 in April).

Thank you for the suggestion!
Martin Maechler,
ETH Zurich

    > -------------------------------------------------------------
    > Rob J Hyndman Professor of Statistics, Monash University
    > www.robjhyndman.com

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