How to exclude certain file names in a folder in R

I think this can be done by applying string manipulations to the list of files, but we would need some sample data to provide a practical example, could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

EDIT: The solution I have in mind would be similar to this

library(stringr)
set.seed(1)
list <- paste0(sample(letters, 10,), sample(1:100, 10))
list
#>  [1] "g21" "j18" "n68" "u38" "e74" "s48" "w98" "m93" "l35" "b71"
exclude <- sample(list, 3)
exclude
#> [1] "b71" "j18" "s48"
list[str_detect(list, exclude, negate = TRUE)]
#> length
#> [1] "g21" "n68" "u38" "e74" "w98" "m93" "l35"

Created on 2019-04-15 by the reprex package (v0.2.1.9000)

2 Likes