Hi Duncan and David, Thank you for explanation. I'm really disappointed with this R "resource". I think that partial match, mainly in function args, must be optional and not default. We can have many problems and lost hours find errors (it occur with me). I tried to find a solution to disable partial match, but it seems that is not possible. Program with hacks for this will be sad.
Best regards! Mario On 11 December 2015 at 15:55, David Winsemius <dwinsem...@comcast.net> wrote: > > > On Dec 11, 2015, at 9:40 AM, Mario José Marques-Azevedo < > mariojm...@gmail.com> wrote: > > > > Dears, > > > > I'm having a weird behaviours when setting arguments in functions. > > > > fn <- function(x, st="mean", b=NULL, col.range="black", ...){ > > dots <- list(...) > > cat("col.range =", col.range, "\n") > > cat("dots =\n") > > print(dots) > > } > > > > fn(1, b=2,col="red") > > > > # Output > > col.range = red > > Argument matching is done with `pmatch`. So "col" is a partial match to > "col.range". > > See ?match.arg > > > > dots = > > list() > > > > Why 'col' arguments are not in ellipses, but setting col.range to 'red'? > > > > If I change the position of ellipses > > > > fn2 <- function(x, ..., st="mean", b=NULL, col.range="black"){ > > dots <- list(...) > > cat("col.range =", col.range, "\n") > > cat("dots =\n") > > print(dots) > > } > > > > fn2(1, b=2, col="red") > > > > # Output > > col.range = black > > dots = > > $col > > [1] "red" > > > > It works! I'm using R version 3.2.2. > > It's been that way 'forever'. > > > > > Best regards! > > > > Mario > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > David Winsemius > Alameda, CA, USA > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.