Thank you. I know grep, but I don't know how to use it for what I need to do.
for instance:
> grep("bcd", "abcd")
returns:
[1] 1
> grep("bcd", "aabcd")
returns:
[1] 1
I need the first one to return 2 ("b" is in the 2nd cell), and the second one
return 3 ("b" is in the 3rd cell).
thanks
> From: [email protected]
> To: [email protected]; [email protected]
> Subject: RE: [R] Find index of a string inside a string?
> Date: Mon, 25 Oct 2010 13:42:23 +0200
>
> For simple searches, use grep with fixed=TRUE.
> Check ?grep.
>
>
> Nick Sabbe
> --
> ping: [email protected]
> link: http://biomath.ugent.be
> wink: A1.056, Coupure Links 653, 9000 Gent
> ring: 09/264.59.36
>
> -- Do Not Disapprove
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of yoav baranan
> Sent: maandag 25 oktober 2010 13:27
> To: [email protected]
> Subject: [R] Find index of a string inside a string?
>
>
> Hi,
> I am searching for the equivalent of the function Index from SAS.
>
> In SAS: index("abcd", "bcd") will return 2 because bcd is located in the 2nd
> cell of the abcd string.
> The equivalent in R should do this:
> > myIndex <- foo("abcd", "bcd") #return 2.
> What is the function that I am looking for?
>
> I want to use the return value in substr, like I do in SAS.
>
> thanks, y. baranan.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.