[R] return value for grep
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Oct 31 04:41:55 CET 2010
On Sat, Oct 30, 2010 at 10:51 PM, Ulrich <ulrich.schlecht at stanford.edu> wrote:
> Hi,
>
> is it possible to easily change the return value for the grep function for
> cases where there is no match, for example the value 0 or "No" instead of
> integer (0) )?
>
Try this:
> Find(length, list(grep("X", letters), 0))
[1] 0
> Find(length, list(grep("X", LETTERS), 0))
[1] 24
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list