[R] functions, `...' and .Rprofile

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon Jul 30 22:19:16 CEST 2001


On 30 Jul 2001, Michael A. Miller wrote:

> I'm experiencing some confusion with the ellipsis argument
> (...).
>
> In my .Rprofile, I have the following functions:
>
>    stderr <- function(x, ...) {
>      sqrt( var(x, ...) / length(x) )
>    }
>    se <- stderr
>
> I can use tapply to calculate some means:
>
>    > tapply( Diameter, factor(Region), mean, na.rm=TRUE )
>             I         II        III         IV          V
>    0.02896429 0.02368421 0.03990476 0.03949315 0.03424021
>
> but, it I try to use my se function, I get an unused argument(s)
> error...
>
>    > tapply( Diameter, factor(Region), se, na.rm=TRUE )
>    Error in FUN(X[[1]], ...) : unused argument(s) (na.rm ...)
>
> If I use stderr instead, I don't get that error:
>
>    > tapply( Diameter, factor(Region), stderr, na.rm=TRUE )
>              I          II         III          IV           V
>    0.005167949 0.004405095 0.006588870 0.006633189 0.001857812
>
> I'm curious about what's going on here.  Any ideas?  Is it just
> that `...' can only be used in directly defined functions and not
> by objects that reference functions?

Not so.  I can't reproduce this putting that code in my .Rprofile.
See ?Startup: .RData is loaded after .Rprofile, so do you have a function
se() in your .RData?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list