[Rd] WISH: Export utils:::findMatches()
Henrik Bengtsson
henrik.bengtsson at gmail.com
Fri Sep 2 23:15:58 CEST 2016
WISH:
I'd like make a plea for utils:::findMatches() to be exported such
that anyone can do:
.DollarNames.MyClass <- function(x, pattern="") {
utils:::findMatches(pattern, names(x))
}
The utils:::findMatches() is agile to the "fuzzy" options, cf.
.DollarNames. It also doesn't erase what's been typed if there is not
match (see below).
ALTERNATIVE:
I'm aware of that utils:::.DollarNames.default almost do the same
thing, but, unfortunately, that does not work for all data type, e.g.
environment-based objects. An alternative to utils:::findMatches() is
to use:
.DollarNames.MyClass <- function(x, pattern="") {
grep(pattern, names(x), value=TRUE)
}
but that has the additional downside to return an empty string "" if
there's no match, which in turn erases whatever the user typed before
hitting TAB.
Thanks
Henrik
More information about the R-devel
mailing list