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

Michael A. Miller mmiller3 at iupui.edu
Mon Jul 30 22:01:26 CEST 2001


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?

Regards, Mike Miller


P.S.  I'm using R.Version()
$platform
[1] "i386-pc-linux-gnu"

$arch
[1] "i386"

$os
[1] "linux-gnu"

$system
[1] "i386, linux-gnu"

$status
[1] ""

$major
[1] "1"

$minor
[1] "3.0"

$year
[1] "2001"

$month
[1] "06"

$day
[1] "22"

$language
[1] "R"

-- 
Michael A. Miller                      mmiller3 at iupui.edu
  Krannert Institute of Cardiology, IU School of Medicine
  Indiana Center for Vascular Biology and Medicine

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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