Here is an example what I want to achieve.
DT1 <- data.table(ZipCodes = c("20202","10101","00023","40404","00001","25002"),
Cities =c("Xi'an/China","Washington D.C","Johannesburg","NewYork/US","Quebeck","Houston"))
#> ZipCodes Cities
#> 20202 Xi'an/China
#> 10101 Washington D.C
#> 00023 Johennesburg
#> 40404 NewYork/US
#> 00001 Quebec
#> 25002 Houston
What I want is when I use grepl search entries that has "X W J and Q" in DT1$Cities and grab entire row to DT2. I couldnt manage it with grepl("[XWJQ]",DT1$cities)
or grepl("^X.*?",DT1$Cities)
In the end DT2 should be seen like this.
DT2 <- data.table(ZipCodes = c("20202","10101","00023","40404","00001"),
Cities =c("Xi'an/China","Washington D.C","Johannesburg","NewYork/US","Quebeck"))
#> ZipCodes Cities
#> 20202 Xi'an/China
#> 10101 Washington D.C
#> 00023 Johennesburg
#> 40404 NewYork/US
#> 00001 Quebec