title: Indexing the columns of matrices in a list by another list
body: <p>Suppose I have a list containing two matrices with different dimensions.</p>
  <pre><code>a &lt;- matrix(rnorm(n=12), nrow = 3, ncol=4)
  b &lt;- matrix(rnorm(n=12), nrow = 4, ncol=3)
  list1 &lt;- list(a, b)
  
  list1
  
  #[[1]]
  #           [,1]       [,2]      [,3]      [,4]
  #[1,] -1.4654114  2.1251278 2.5363265 0.3127435
  #[2,]  0.5701815 -1.0877491 0.6314599 1.5293045
  #[3,]  2.0811299  0.3109243 0.2300760 0.5495488
  #
  #[[2]]
  #          [,1]      [,2]     [,3]
  #[1,] 0.9082071 1.7337076 2.207299
  #[2,] 2.1287871 1.6839454 1.527546
  #[3,] 0.8175804 0.8086223 1.165589
  #[4,] 0.7410989 0.8237012 1.729501
  </code></pre>
  <p>Additionally, I have a list containing two vectors.</p>
  <pre><code>a2 &lt;- c(&quot;yes&quot;, &quot;no&quot;, &quot;yes&quot;, &quot;yes&quot;)
  b2 &lt;- c(&quot;no&quot;, &quot;yes&quot;, &quot;no&quot;)
  list2 &lt;- list(a2, b2)
  
  list2
  
  #[[1]]
  #[1] &quot;yes&quot; &quot;no&quot;  &quot;yes&quot; &quot;yes&quot;
  #
  #[[2]]
  #[1] &quot;no&quot;  &quot;yes&quot; &quot;no&quot; 
  </code></pre>
  <p>How can I index to only the columns in list1 that correspond to where list2 says &quot;yes&quot;?</p>
  <p>In other words, can I index the columns of each matrix in list1 by the character values in list2?</p>