[R] search for string insider a string

2009-03-13 Thread Tan, Richard
Hi, sorry if it is a too stupid question, but how do I a string search in R: I have a dataframe A with A$test like: test1 bcdtestblabla2.1bla cdtestblablabla3.88blabla and I want to search for string that start with 'dtest' and ends with number and return the location of that substring and

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 - ctest1,

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

Re: [R] search for string insider a string

2009-03-13 Thread Gabor Grothendieck
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 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