[R] grep command

Steven Yen syen04 at gmail.com
Tue May 3 12:38:32 CEST 2016


Dear all
In the grep command below, is there a way to identify only "age" and
not "age2"? Thanks.

> x<-c("abc","def","rst","xyz","age","age2")
> x
[1] "abc"  "def"  "rst"  "xyz"  "age"  "age2"
> grep("age2",x)
[1] 6
> grep("age",x) # I need to grab "age" only, not "age2"
[1] 5 6

Also, I post message to r-help at r-project.org and that's subject to
approval by the list moderator. Am I sending it to the wrong address?



More information about the R-help mailing list