From cyc||cgroup-z1 @end|ng |rom y@hoo@com  Thu Aug 15 20:31:01 2019
From: cyc||cgroup-z1 @end|ng |rom y@hoo@com (Cyclic Group Z_1)
Date: Thu, 15 Aug 2019 18:31:01 +0000 (UTC)
Subject: [Rd] Feature request: non-dropping regmatches/strextract
In-Reply-To: <CAF8bMcaoxRZvQ0hJd_HygP2bOi-816UXybZEJDz3OWR6r56ZRA@mail.gmail.com>
References: <2012653205.221487.1565848601638.ref@mail.yahoo.com>
 <2012653205.221487.1565848601638@mail.yahoo.com>
 <CAF8bMcaoxRZvQ0hJd_HygP2bOi-816UXybZEJDz3OWR6r56ZRA@mail.gmail.com>
Message-ID: <261022177.555187.1565893861815@mail.yahoo.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



[Rd] Feature request: non-dropping regmatches/strextract
Cyclic Group Z_1