Hello:

I'm not on the "r-devel" list, but I just modified "match.arg" from R 1.6.2 for Windows to accept a vector for "arg".

Is it appropriate that I send such things to this email address for consideration for inclusion in a future release?

I just compared this with "match.arg" in S-Plus 6.1 for Windows. There, I got the following:

> match.arg(c("a","b"), c("aa", "bb"))
[1] "aa" "bb"

However, match.arg(c("a", "b")) in a test function with "default" = c("aa", "bb") returned only "a"; the following returns c("aa", "bb").

Thanks for all your hard work in developing this marvelous product.

Sincerely,
Spencer Graves

match.arg <-
function (arg, choices)
{
if (missing(choices)) {
formal.args <- formals(sys.function(sys.parent()))
choices <- eval(formal.args[[deparse(substitute(arg))]])
}
# cat("choices =", choices, "\n")
for(j in 1:length(arg)){
if (all(arg[j] == choices))
arg[j] <- choices[1]
else{
i <- pmatch(arg[j], choices)
if (is.na(i))
stop(paste("ARG should be one of", paste(choices, collapse = ", "),
sep = " "))
if (length(i) > 1)
stop("there is more than one match in match.arg")
arg[j] <- choices[i]
}
}
arg
}

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-devel

Reply via email to