[R] problem with repeated formal arguments and ...

From: Ross Boylan <ross_at_biostat.ucsf.edu>
Date: Fri 19 Aug 2005 - 04:32:09 EST


I want to add an argument if it is not present. Following the Green Book, p. 337:
test <- function(x, ...){
  dots <- list(...)
  if (!hasArg(from))
    from <- 0
  else

    from <- dots$from
  curve(x, from=from, ...)
}

> test(sin)
> test(sin, from=4)

Error in curve(x, from = from, ...) : formal argument "from" matched by multiple actual arguments

The FAQ says, in the section on differences between R and S, "R disallows repeated formal arguments in function calls."

That seems a perfectly reasonable rule, but how do I handle this situation?

-- 
Ross Boylan                                      wk:  (415) 502-4031
530 Parnassus Avenue (Library) rm 115-4          ross@biostat.ucsf.edu
Dept of Epidemiology and Biostatistics           fax: (415) 476-9856
University of California, San Francisco
San Francisco, CA 94143-0840                     hm:  (415) 550-1062

______________________________________________
R-help@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
Received on Fri Aug 19 04:38:55 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:53 EST