title: Group R objects into a list
body: <p>I have loaded a series of SpatialPolygonsDataFrames into my workspace. Each of the named objects has either <code>"_adm0"</code>, <code>"_adm1"</code>, or <code>"_adm2"</code> attached to the country abreviation. For Germany, this would look like <code>"DEU_adm0"</code>, <code>"DEU_adm1"</code>, and <code>"DEU_adm2"</code>.</p>
  
  <p>I'm trying to gather all of the "_adm0" data frames into a list which can then be operated on by ldply and fortify. I could do that with, </p>
  
  <p><code>mylist &lt;- list(DEU_adm0, FRA_adm0, RUS_adm0, etc...)</code> where I write out all of the countries that I want to be included in the list.</p>
  
  <p>But, how do I grab all of the <code>"_adm0"</code> data frames by a pattern?</p>
  
  <p>I have started with the code below but it doesn't give me the desired result as writing out </p>
  
  <pre><code>adm0list &lt;- ls()[str_detect(ls(), "_adm0")]
  
  mylist   &lt;- sapply(adm0list, function(x) get(x))
  </code></pre>
  
  <p>or alternatively,</p>
  
  <pre><code>mylist   &lt;-  mget(adm0list, .GlobalEnv)
  </code></pre>
  
  <p>I do get a list of objects with the <code>sapply</code> method, and using <code>mget()</code>, but I'm not seeing why those lists are different than using <code>list()</code> with the object names directly. I suspect the answer to that question will tell me why <code>ldply</code> + <code>fortify</code> works with the <code>list()</code>method but not the other two.</p>