[R] Branching on 'grep' returns...

2006-07-26 Thread Allen S. Rout
Greetings, all. I'm fiddling with some text manipulation in R, and I've found something which feels counterintuitive to my PERL-trained senses; I'm hoping that I can glean new R intuition about the situation. Here's an example, as concise as I could make it. trg-c(this,that) # these two

Re: [R] Branching on 'grep' returns...

2006-07-26 Thread Gabor Grothendieck
If you are using grep then I think you have it right. Note that this %in% trg is also available. On 26 Jul 2006 11:16:25 -0400, Allen S. Rout [EMAIL PROTECTED] wrote: Greetings, all. I'm fiddling with some text manipulation in R, and I've found something which feels counterintuitive

Re: [R] Branching on 'grep' returns...

2006-07-26 Thread Thomas Lumley
On Wed, 26 Jul 2006, Allen S. Rout wrote: # These all fail with error 'argument is of length zero' # if ( grep(other,trg) ) { cat(Y\n) } else { cat(N\n) } # if ( grep(other,trg) == TRUE) { cat(Y\n) } else { cat(N\n) } # if ( grep(other,trg) == 1) { cat(Y\n) } else { cat(N\n) } # This says