[R] simple q: returning a logical vector of substring matches

2007-01-20 Thread lindeman
I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a <- c("apple", "pear") and I want a logical vector of whether each of these strings contains "ear" (in this case, F T). What is the idiom? Quizzically, Mark Lindeman _

Re: [R] simple q: returning a logical vector of substring matches

2007-01-20 Thread Christos Hatzis
On Behalf Of [EMAIL PROTECTED] Sent: Saturday, January 20, 2007 1:31 PM To: r-help@stat.math.ethz.ch Subject: [R] simple q: returning a logical vector of substring matches I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a <- c("apple", "pe

Re: [R] simple q: returning a logical vector of substring matches

2007-01-20 Thread Marc Schwartz
On Sat, 2007-01-20 at 13:30 -0500, [EMAIL PROTECTED] wrote: > I'm a relative R novice, and sometimes the simple things trip me up. > > Suppose I have > > a <- c("apple", "pear") > > and I want a logical vector of whether each of these strings contains > "ear" (in this case, F T). What is the i

Re: [R] simple q: returning a logical vector of substring matches

2007-01-20 Thread jim holtman
try 'regexpr' > a <- c("apple", "pear") > regexpr('ear',a)!=-1 [1] FALSE TRUE > On 1/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I'm a relative R novice, and sometimes the simple things trip me up. > > Suppose I have > > a <- c("apple", "pear") > > and I want a logical vector of w

Re: [R] simple q: returning a logical vector of substring matches

2007-01-20 Thread Gabor Grothendieck
Using the builtin month.abb try this: regexpr("ov", month.abb) > 0 Although not needed here, if "ov" were a character string that could have special characters such as . and * that have special meaning in a regular expression then do this to prevent such interpretation: regexpr("ov", month.a