I am trying to make a subset of my data table (counties) consisting of rows where the id number ends in zero. I have tried using grep and %like% but these are specific to the entire id value and not just the last integer value.

I am trying to make a subset of my data table (counties) consisting of rows where the id number ends in zero. I have tried using grep and %like% but these are specific to the entire id value and not just the last integer value.

Use the sqldf package: 
library(sqldf)
sqldf("select * from dat where Id like '%0'")
OR the data.table package: As suggested by Frank
dat[id %like% "0$"]
