Look at the gsubfn package, it gives more options and will probably make what you are trying to do easier.
-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [email protected] 801.408.8111 > -----Original Message----- > From: [email protected] [mailto:r-help-boun...@r- > project.org] On Behalf Of kayj > Sent: Friday, February 26, 2010 11:27 AM > To: [email protected] > Subject: [R] using grep > > > Hi All, > > I have a character vector with naems of cities in the us. I need to > extract > the number that appear after the word "New York", for example, > > x<-c("P Los Angeles44AZ", "P New York722AZ", "K New York20") > > I want the results to be > > 722, 20 > > > cab I use the grep function, if so how? > I appreciate your help, thanks, > > -- > View this message in context: http://n4.nabble.com/using-grep- > tp1571102p1571102.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [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. ______________________________________________ [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.

