[R] Index of Character

David Winsemius dwinsemius at comcast.net
Thu Jul 1 05:21:10 CEST 2010


On Jun 30, 2010, at 10:48 PM, harsh yadav wrote:

> Hi,
>
> I am a newbie to R and this may be too simple to ask.
>
> I am trying to find out a string function in R that returns the  
> index of a
> character.
>
> For e.g. indexOf("Test1234", '4') would return 8.

?grep
?strsplit

 > grep("4", strsplit("Test1234", "")[[1]])
[1] 8


>
> Is there a similar function in R.
> I tried searching the documentation and could find other useful string
> functions, but not the index function.
>
> Thanks in advance.
>
> Regards,
> Harsh Yadav



More information about the R-help mailing list