Skip to content
Prev 198956 / 398503 Next

Exact String Compare in R?

Dear R users:
Here's a barebones example of what I can't make work. 
As you can see, regexpr() does not perform an exact string match, which only
occurs in row 1 of these data frames. Instead, as it's supposed to do, it
finds "b" in "bb" and "c" in "cc". Does anybody know what function I can use
such that only the first rows would be matched (ie, exact string match?)
I've also tried simply using the == operator, in which case i get the
error:"level sets of factors are different"

Thank you in advance, 
B
+        cat("identical match on row #", i, "\n")
+        i=i+1 
+         if (i>3) break 
+ }
identical match on row # 1 
identical match on row # 2 
identical match on row # 3