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) )
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 jonsle...@gmail.com wrote:
Hi,
A
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,
Thanks, Jim and Stephen!
On Sat, Dec 19, 2009 at 3:57 PM, jim holtman jholt...@gmail.com 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
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 jonsle...@gmail.com wrote:
Hi,
A noobie question: I'm simply trying to run a conditional statement that
evaluates if a substring
5 matches
Mail list logo