extract elements from a list based on a vector of indices
<p>I want to extract elements from a list based on indices stored in a separate vector. </p>

<p>This is my attempt at it:</p>

<pre><code>list_positions&lt;-c(2,3,4)
my_list&lt;-list(c(1,3,4),c(2,3,4,5,6),c(1,2,3,4,6))

my_fun&lt;-function(x,y){
  x[y]
}

mapply(my_fun,x=my_list,y=list_positions)
</code></pre>

<p>Maybe somebody can suggest a faster solution. My list is has around 14 million elements. I tried parallel solutions, where instead of mapply I used clusterMap but still I would like to have a better performance.</p>