Hi Jonathan,
The function "isTRUE" is useful for this sort of thing:
isTRUE(pmatch("hi", "hop")) evaluates to FALSE.
--Gray
On Sat, Dec 19, 2009 at 12:47 PM, Jonathan wrote:
> Hi,
> A noobie question: I'm simply trying to run a conditional statement that
> evaluates if a substring is found w
Thanks, Jim and Stephen!
On Sat, Dec 19, 2009 at 3:57 PM, jim holtman wrote:
> try using 'grepl'
>
> > if( grepl("hi", "hop", fixed = TRUE) ){
>
> + print('yes, your substring is in your string')
> + } else print('no, your substring is not in your string')
> [1] "no, your substring is not
Hi Jonathan,
grep() returns a vector giving either the indices of the elements of
'x' that yielded a match or, if 'value' is 'TRUE', the matched elements
of 'x' (quoting from the help page, see ?grep).
So you probably want to test whether this vector is empty or not - in
other words, whethe
try using 'grepl'
> if( grepl("hi", "hop", fixed = TRUE) ){
+ print('yes, your substring is in your string')
+ } else print('no, your substring is not in your string')
[1] "no, your substring is not in your string"
>
On Sat, Dec 19, 2009 at 3:47 PM, Jonathan wrote:
> Hi,
> A noobie ques
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)
5 matches
Mail list logo