[R] Parenthesis recognition with grep
Sébastien
pomchip at free.fr
Sun Aug 31 16:28:50 CEST 2008
Dear R-users,
I need to dynamically recognize the index of a given string myStr in a
vector of string. The problem is that myStr might contain parenthesis,
causing grep not to recognize it the way I want (see below). The help
mentions that the pattern used by grep should be in the POSIX format...
I guess the problem is here; unfortunately, I am not familiar with the
subtleties of the POSIX format
ex:
myStr <- "YD(001)"
headers <-c("TD", "YD(001)", "YD(002)", "T", "Y(001)", "Y(002)")
grep(myStr, headers)
How should I modify my grep call to get the match right?
Thank you for your help,
Sebastien
More information about the R-help
mailing list