[R] return value for grep

Duncan Murdoch murdoch.duncan at gmail.com
Sun Oct 31 11:58:06 CET 2010


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 (which returns a vector of indices or 
matches).

Duncan Murdoch



More information about the R-help mailing list