[R] Looking for equivalent for "strstr"
    David Winsemius 
    dwinsemius at comcast.net
       
    Thu May  5 23:00:39 CEST 2011
    
    
  
On May 5, 2011, at 4:55 PM, Worik R wrote:
> Friends
>
> This is an elementary question.  Is there is a built in R function for
> finding a sub-string in another string?  Like strstr in C.
>
> I can easily roll my own, but if there is a built in that is one  
> less thing
> I can do wrong!
I have no acquaintance with that function, but perhaps:
?grep
regexpr :
"returns an integer vector of the same length as text giving the  
starting position of the first match or -1 if there is none, ..."
 > tst <- "abcde"; regexpr("bc", tst)
[1] 2
attr(,"match.length")
[1] 2
-- 
David Winsemius, MD
West Hartford, CT
    
    
More information about the R-help
mailing list