I am working with some US govt data which has a lengthy list of cities and zip codes. After some work, the data is in the following format.
dat1 = data.frame
I think two grepl expressions should do the trick:
> dat2[ !( grepl("City", dat2$tag) & grepl("^\\d", dat2$keyword) ) , ]
keyword tag
1 Bremen AlabamCity
2 Brent AlabamCity
4 Chelsea, AL AlabamaCityST
5 Bailytown, Alabama AlabamaCityState
7 54023 AlabamaZipCode
8 54024 AlabamaZipCode
You are eliminating the rows where there are digits in keyword and "City" in tag