title: Make list of objects in global environment matching certain string pattern
body: <p>I have 10 data frames in the global environment- 5 with a name pattern and other 5 with another naming pattern. I want to put the dataframes with same naming pattern into a list each (two lists - one for each pattern) so ultimately I can run checks on each of them using <code>lapply</code> like this : </p>
  
  <pre><code> lapply(listofdataframes, function(x) range(x[ , "date"]))`
  </code></pre>
  
  <p>The naming patterns are thus - <code>Pattern 1</code> : <code>q32013local</code>, <code>q42013local</code>, <code>q12014local</code>, etc.</p>
  
  <p><code>Pattern 2</code> : <code>q32013national</code>, <code>q42013national</code> etc. </p>
  
  <p>I have used this in the past:</p>
  
  <pre><code> Filter(function(x) is(x, "data.frame"), mget(ls()))` 
  </code></pre>
  
  <p>but it obviously makes a list of all data frames in global environment. </p>
  
  <p>I was looking for how to use <code>grep</code> and <code>ls</code> together . I found the <code>bash</code> equivalent questions for it on SO here <a href="https://stackoverflow.com/questions/1447625/list-files-with-certain-extensions-with-ls-and-grep">List files with certain extensions with ls and grep</a> but no R equivalent. I did refer these two related questions but they are quite different :</p>
  
  <p><a href="https://stackoverflow.com/questions/13795526/return-elements-of-r-list-as-independent-objects-in-global-environment">Return elements of list as independent objects in global environment</a> , <a href="https://stackoverflow.com/questions/25509879/how-can-i-make-a-list-of-all-dataframes-that-are-in-my-global-environment">How can I make a list of all dataframes that are in my global environment?</a></p>