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
>
> which(headers%in%myStr)
> [1] 2
>
>
> HTH,
>
> Jorge
>
>
>
> On Sun, Aug 31, 2008 at 10:28 AM, Sébastien <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     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
>
>     ______________________________________________
>     R-help@r-project.org <mailto:R-help@r-project.org> 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.
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to