Hi Julie, match is not exactly what you need, as it works with regular expressions and takes anything what includes a letter "b". For your case, there is perfectly suitable
which(nom=="b") nom <- c("a","b","ab", "b") which(nom=="b") [1] 2 4 Jan - - - Original message: - - - From: [EMAIL PROTECTED] Send: 8.7.2004 9:24:58 To: [EMAIL PROTECTED] Subject: [R] Problem with the grep function Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern="b", I would to obtain 2 because "b" is on the second position. First program : nom <- c("a","b","ab") grep("b",nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html