[R] bug or no?

Gabor Grothendieck ggrothendieck at myway.com
Tue Aug 24 21:22:31 CEST 2004


Note that R requires that anything placed AFTER the ... 
to be matched exactly so one can force exact matching
on sb by putting it after the ... like this:

R> temp<-function(...,sb) print(sb)
R> temp(2,s=3)
Error in print(sb) : Argument "sb" is missing, with no default



Chuck Cleland <ccleland <at> optonline.net> writes:

: 
: I don't think it's a bug, it's partial matching of 
: argument names.  To avoid it, use exact argument names in 
: your call to the function:
: 
: temp(sb=2,s=3)
: [1] 2
: 
:    From the R language definition:
: 
: "Argument matching: Formal arguments are matched to supplied 
: arguments first by exact matching on tags, then by partial 
: matching on tags, and finally by positional matching."
: 
: http://cran.r-project.org/doc/contrib/R_language.pdf
: 
: Richard Morey wrote:
: > The following code prints [1] 2, as it should
: > 
: > temp<-function(ab,...){
: > print(ab)
: > }
: > temp(2,s=3)
: > 
: > However, this code prints [1] 3:
: > 
: > temp<-function(sb,...){
: > print(sb)
: > }
: > temp(2,s=3)
: > 
: > It should still print [1] 2. It appears
: > that if a variable in ... begins with the same letter as another variable,
: > the value in the variable in ... overwrites the value in the variable with
: > the same first letter.
: > 
: > I didn't see this bug reported elsewhere.
: > 
: > Richard Morey
: > 
: > Is this a bug or am I missing something?
: > 
: > output of R.version
: > platform i686-pc-linux-gnu
: > arch     i686
: > os       linux-gnu
: > system   i686, linux-gnu
: > status
: > major    1
: > minor    9.1
: > year     2004
: > month    06
: > day      21
: > language R
: > 
: > 
:




More information about the R-help mailing list