Re: [R] search for string insider a string

2009-03-13 Thread Gabor Grothendieck
-Original Message- > From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] > Sent: Friday, March 13, 2009 2:18 PM > To: Tan, Richard > Cc: r-help@r-project.org > Subject: Re: [R] search for string insider a string > > Try this.  We use regexpr to get the positions

Re: [R] search for string insider a string

2009-03-13 Thread Tan, Richard
That works. I want the position just for the purpose of my later manual check. Thanks a lot Gabor. -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Friday, March 13, 2009 2:18 PM To: Tan, Richard Cc: r-help@r-project.org Subject: Re: [R] search for

Re: [R] search for string insider a string

2009-03-13 Thread Gabor Grothendieck
Try this. We use regexpr to get the positions and strapply puts the values in list s. The unlist statement converts NULL to NA and simplifies the list, s, to a numeric vector. For more info on strapply see http://gsubfn.googlecode.com library(gsubfn) # strapply x <- c"test1", "bcdtestblabla2.