I have 891 tif images which I list them. I want to remove 10 specific images from the list based on their names (i.e., in the end I want my list to have 881 images). I tried many things but I am getting errors based on what I've tried. For example, my last try was:
l = list.files("path", pattern = ".tif$", full.names = FALSE)
remove <- c("pop", "tirs", "agbh", "ndvi", "road", "poi", "blue", "nir", "swir", "red")
l[l != remove]
I get this error: comparison (2) is possible only for atomic vectors.
Another try was:
l[l != c("pop", "tirs", "agbh", "ndvi", "road", "poi", "blue", "nir", "swir", "red")]
I got this warning: longer object length is not multiple of shorter object lenght.
How can I remove multiple elements from a list based on their names?