[Rd] bug in `pmatch' (error with too long 'choices')?
Tony Plate
tplate at acm.org
Fri Oct 30 18:38:07 CET 2009
I believe the answer is that you are missing something: partial matching.
The 651'st elt of colors() is "whitesmoke", so it is ambiguous whether
"whit" matches "white" or "whitesmoke". When you leave out the 651'st
elt, "whit" happily matches "white".
> which(substring(colors(), 1, 4)=="whit")
[1] 1 651
> colors()[which(substring(colors(), 1, 4)=="whit")]
[1] "white" "whitesmoke"
> match.arg("whit", colors()[1:650])
[1] "white"
> match.arg("whit", colors())
Error in match.arg("whit", colors()) :
'arg' should be one of “white”, “aliceblue”, ...
> match.arg("whit", colors()[c(1,651)])
Error in match.arg("whit", colors()[c(1, 651)]) :
'arg' should be one of “white”, “whitesmoke”
>
-- Tony Plate
Joerg van den Hoff wrote:
> I observed the following:
>
> match.arg("white", colors())
>
> yields 'white', but
>
> match.arg("whit", colors())
>
> yields:
>
> `Error in match.arg("whit", colors()) :
> 'arg' should be one of "white", "aliceblue", '...
>
> this message actually comes from `pmatch'. using a suitable subset of
> `colors()' works OK. the precise length were the error occurs seems to
> depend on `arg' and `choices'. e.g.
>
> match.arg("whit", colors()[1:650])
>
> works
>
> but the limit seems not be fixed. in another setting it
> happend around a length of `choices' of around 130. maybe a memory management related
> bug? or am I missing something?
>
> regards,
> joerg
>
>
>
> platform powerpc-apple-darwin8.11.1
> arch powerpc
> os darwin8.11.1
> system powerpc, darwin8.11.1
> status
> major 2
> minor 9.2
> year 2009
> month 08
> day 24
> svn rev 49384
> language R
> version.string R version 2.9.2 (2009-08-24)
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
More information about the R-devel
mailing list