[R] Does anyone else think this might be worth a warning?!?

Felix Andrews felix at nfrac.org
Mon Aug 20 05:01:51 CEST 2007


I do think this is worth a warning.
mean.default could do something like
if (length(list(...)) > 0) warning("extra arguments ignored")

The same could also apply to many other methods of S3 generic
functions which are forced to include the formal argument `...` in the
signature but do not use it.

Felix


On 8/19/07, Matthew Walker <m.g.walker at massey.ac.nz> wrote:
> Hi,
>
> I was *very* surprised by this little trick for new players: mean() only
> considers its first argument!
>
>  > mean(1,1,2)
> [1] 1
>  > mean(2,1,1)
> [1] 2
>
>
> I found this very different behaviour to max():
>
>  > max(1,1,2)
> [1] 2
>  > max(2,1,1)
> [1] 2
>
>
>
> Perhaps this is the wrong list to ask, but does anyone else think this a
> little on the interesting side?  Is it not possible to detect a first
> argument of length one in the presence of other un-named arguments and
> at least produce a warning?
>
>
> Cheers,
>
>
> Matthew
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
Felix Andrews / 安福立
PhD candidate
Integrated Catchment Assessment and Management Centre
The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
voice:+86_1051404394 (in China)
mobile:+86_13522529265 (in China)
mobile:+61_410400963 (in Australia)
xmpp:foolish.android at gmail.com
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8



More information about the R-help mailing list