Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Gray Calhoun
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

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Jonathan
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

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Stephan Kolassa
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

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread jim holtman
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

[R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Jonathan
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)