R list files with multiple conditions

capm picture capm · Aug 3, 2013 · Viewed 41.9k times · Source

I want to list all files in a directory that met certain conditions (date and currency). So with only one condition the argument pattern in list.files works well:

    file.ls <- list.files(path='~/DATA/PiP/Curvas/',pattern='20130801')

For multiple conditions I've tried:

    file.ls <- list.files(path='~/DATA/PiP/Curvas/',pattern=c('20130801','USD'))

But had the same result as the first one. Is there a way to have multiple criteria in pattern argument of list.files?

Answer

Metrics picture Metrics · Aug 3, 2013
file.ls <- list.files(path='~/DATA/PiP/Curvas/',pattern="20130801|USD")