i have a table country called gDat with column country, now i want to find out the country starts with Mal with this code
grep('Mal', levels(gDat$country))
but its returns only the id of that country (not the country name), how to solve this?
>Solution :
Use grepl with the regex pattern ^Mal:
countries <- gDat$country[grepl("^Mal", gDat$country)]