Hi,
   A noobie question:  I'm simply trying to run a conditional statement that
evaluates if a substring is found within a larger string.  I find that if it
IS found, my function returns TRUE (great!), but if not, the condition does
not evaluate to FALSE.

ex):

if( grep("hi", "hop", fixed = TRUE) )
      print('yes, your substring is in your string')
else print('no, your substring is not in your string')

alternatively, I could replace grep with pmatch:

if (pmatch('hi','hop'))
      print('yes, your substring is in your string')
else print('no, your substring is not in your string')


The first example, using grep, returns logical(0).  The second, using
pmatch, returns NA.  Any idea how to convert either of those to FALSE, or
else a different function that would do the trick?

Thanks,
Jon

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to