# Create data frame
ABData <- data.frame(a = c("London, UK", "Oxford, UK", "Berlin, DE",
"Hamburg, DE", "Oslo, NO"),
b = c(8, 0.1, 3, 2, 1))
# Keep only data from Germany (DE)
ABGermany <- grepl.sub(data = ABData, pattern = "DE", Var = "a")
Run the code above in your browser using DataLab