capm capm - 1 year ago 352
R Question

R list files with multiple conditions

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

works well: <- list.files(path='~/DATA/PiP/Curvas/',pattern='20130801')

For multiple conditions I've tried: <- 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
argument of

Answer Source
 Filter(function(x) grepl("USD", x),

alternatively, you could construct a regular expression for pattern that only matches filenames containing both strings, but that's a wizard's game.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download