R list files with multiple conditions
Filter(function(x) grepl("USD", x), file.ls)
alternatively, you could construct a regular expression for pattern that only matches filenames containing both strings, but that's a wizard's game.
file.ls <- list.files(path='~/DATA/PiP/Curvas/',pattern="20130801|USD")
Here it is:
file.ls2 = intersect(list.files(pattern = "20130801"), list.files(pattern = "USD"))
In line with Baptiste and the answer on this post (list.files pattern argument in R, extended regular expression use), you can use the following expression:
file.ls <- list.files(path='~/DATA/PiP/Curvas/',
pattern=glob2rx("*20130801*USD*"))
Where *
is the wildcard.