title: How can I select multiple elements from the nth vector in a list?
body: <p>I am trying to take in a character vector, do some operations on it, and then extract only the elements that match certain criteria.</p>
  <blockquote>
  <p>c(&quot;a&quot;, &quot;b&quot;, &quot;b&quot;) %&gt;% list(., which(.==&quot;b&quot;)) %&gt;% {.[[1]][[.[[2]]]]}</p>
  </blockquote>
  <p>the list is made out of the character vector as the first element and an index vector - of the elements I want to extract - as the second element. But, when I try to use list subsetting in the final step, I get the error</p>
  <blockquote>
  <p>Error in .[[1]][[.[[2]]]] :    attempt to select more than one element
  in vectorIndex</p>
  </blockquote>
  <p>How can I get the desired output:</p>
  <blockquote>
  <p>c(&quot;b&quot;, &quot;b&quot;)</p>
  </blockquote>