Skip to content
Back to formatted view

Raw Message

Message-ID: <261022177.555187.1565893861815@mail.yahoo.com>
Date: 2019-08-15T18:31:01Z
From: Cyclic Group Z_1
Subject: Feature request: non-dropping regmatches/strextract
In-Reply-To: <CAF8bMcaoxRZvQ0hJd_HygP2bOi-816UXybZEJDz3OWR6r56ZRA@mail.gmail.com>

I do think keeping the default behavior is desirable for backwards compatibility; my suggestion is not to change default behavior but to add an optional argument that allows a different behavior. Although this can be implemented in a user-defined function, retaining empty matches facilitates programmatic use, and seems to be something that should be available in base R. It is available, for example, in MATLAB, a comparable array language.

Alternatively, perhaps a nomatch (or maybe emptymatch) argument in the spirit of `[.data.table`? That is, an argument nomatch where nomatch = NULL (the default) results in drops for vector outputs and character(0) for list outputs and nomatch = NA results in insertion of NA_character_, and nomatch = '' results in insertion of empty string.

I can submit proposed patch code if others think this is a good idea.

What are your thoughts on the proposed alteration to (currently nonexported) strextract? I assume (maybe wrongly) that the plan is to eventually export that function.

Thank you,
CG