 <p>The argument you're passing to <code>pattern =</code> is where things are going wrong I believe. This three-step approach might get you the desired result:</p> <pre><code># Extract all .rds files list &lt;- list.files("Data/", pattern =".rds", full.names = TRUE) # Define pattern for grepl files &lt;- c(20388, 20389, 20390) pattern &lt;- paste(files, sep="", collapse="|") # Results in pattern [1] "20388|20389|20390" # grepl will interpret "|" as "or" # Now we can subset list with the following list[grepl(pattern,list)] </code></pre>