You need to add word boundary anchors (\b
) around your search strings so only entire words will be matched (i. e. words surrounded by non-word characters or start/end of string, where “word character” means \w
, i.e. alphanumeric character).
Try
grep("\\bTH\\b",t3, value=T)