This is minor, but important. Characters including . and : have a special meaning in regex, and need to be specified as literal characters for R's grep to treat them as such. Without them, R will first try to interpret them as part of a regex command sequence, and if that fails (which it would here), will presume they are meant as string literals. This skips the first step, and tells R's interpreter to treat them just as literal strings.
This is minor, but important. Characters including
.
and:
have a special meaning inregex
, and need to be specified as literal characters for R'sgrep
to treat them as such. Without them, R will first try to interpret them as part of aregex
command sequence, and if that fails (which it would here), will presume they are meant as string literals. This skips the first step, and tells R's interpreter to treat them just as literal strings.