title: Sparklyr : Trying to access the elements of a vector stored in a column using an exterior variable as index
body: <p>I have asked the very same question <a href="https://stackoverflow.com/questions/51088748/dplyr-trying-to-access-the-elements-of-a-vector-stored-in-a-column-using-an-ex">here</a> and got a nice answer for dplyr but now I want to do the same on sparklyr.</p>
  
  <p>So I have a spark dataframe where one of the columns contains vectors/lists. I'd like to create a column that contain the element of the vector with index i (an exterior variable).</p>
  
  <p>e.g. with i = 2</p>
  
  <p><a href="https://i.stack.imgur.com/OyZSY.png" rel="nofollow noreferrer">link to data</a></p>
  
  <p>In dplyr the solution is:</p>
  
  <pre><code>data &lt;- data %&gt;%
    mutate(element = sapply(list_x, "[", i))
  </code></pre>
  
  <p>But this doesn't work in sparklyr as <code>sapply</code> doesn't exist in sparklyr.</p>