Re: [R] return value for grep

2010-10-31 Thread Duncan Murdoch
Ulrich 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) )? It sounds like you might want grepl (which returns a vector of TRUE and FALSE values) rather than grep (whi

Re: [R] return value for grep

2010-10-30 Thread David Winsemius
On Oct 30, 2010, at 11:13 PM, David Winsemius wrote: On Oct 30, 2010, at 10:51 PM, Ulrich 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) )? Seems like is shou

Re: [R] return value for grep

2010-10-30 Thread Gabor Grothendieck
On Sat, Oct 30, 2010 at 10:51 PM, Ulrich 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(l

Re: [R] return value for grep

2010-10-30 Thread David Winsemius
On Oct 30, 2010, at 10:51 PM, Ulrich 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) )? Seems like is should be pretty easy. Test for length(grep(...)) == 0 or

[R] return value for grep

2010-10-30 Thread Ulrich
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) )? Thanks, Uli __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/