[R] Parenthesis recognition with grep

2008-08-31 Thread Sébastien
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

Re: [R] Parenthesis recognition with grep

2008-08-31 Thread Jorge Ivan Velez
Dear Sébastien, Is this what you want? which(myStr==headers) [1] 2 which(headers%in%myStr) [1] 2 HTH, Jorge On Sun, Aug 31, 2008 at 10:28 AM, Sébastien [EMAIL PROTECTED] wrote: Dear R-users, I need to dynamically recognize the index of a given string myStr in a vector of string. The

Re: [R] Parenthesis recognition with grep

2008-08-31 Thread Sébastien
Hi Jorge, This is doing the work just fine. Thank you ! However, I would like to know what should be done with the grep call... just for my personal education :) Sebastien Jorge Ivan Velez a écrit : Dear Sébastien, Is this what you want? which(myStr==headers) [1] 2

Re: [R] Parenthesis recognition with grep

2008-08-31 Thread Charilaos Skiadas
Try: myStr - YD\\(001\\) In POSIX format, or in most such formats in fact, special characters like parentheses have a particular meaning, and need to be escaped if they are to have the parenthesis meaning. This is done typically by putting a backslash in front of them. Since however a