I can select a single value for "ds-01" only how can i filter multiple characters at once the value to be filtered in district_name columun : district_name=c("ds-01", "ds-02", "ds-03", ds-04")
data.shp<- shapefile("data.shp") ds-01<- data.shp[data.shp$district_name=="ds-01", ]
is there a possible solution for this
Have you considered something along the lines of %in% infix operator instead of equals ==, e.g.
%in%
==
data.shp<- shapefile("data.shp") ds_1234<- data.shp[data.shp$district_name %in% c("ds-01", "ds-02", "ds-03", "ds-04"), ]
alternatively using {dplyr} workflow
library(dplyr) data_filtered <- data.shp %>% filter(district_name %in% c("ds-01", "ds-02", "ds-03", "ds-04"))
Thanks a lot!!!