Re: [R] Looking for position of character in a string

2008-10-01 Thread Doran, Harold
> s1 <- "Hello.World" > which(strsplit(s1, '')[[1]]=='.') [1] 6 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of phoebe kong > Sent: Wednesday, October 01, 2008 2:56 PM > To: r-help@r-project.o

Re: [R] Looking for position of character in a string

2008-10-01 Thread Henrique Dallazuanna
Try this: gregexpr("\\.", X) On Wed, Oct 1, 2008 at 3:56 PM, phoebe kong <[EMAIL PROTECTED]> wrote: > Hi all, > > I would like to check if a string contains "." in it. If yes, I would like > to know the position of "." in the string. > > Eg: X<-"NM1236.3" > > In above example, "." is at position

[R] Looking for position of character in a string

2008-10-01 Thread phoebe kong
Hi all, I would like to check if a string contains "." in it. If yes, I would like to know the position of "." in the string. Eg: X<-"NM1236.3" In above example, "." is at position 7. I tried functions grep() and match(). It seems they couldn't detect ".". Thanks in advance for your help, Sit