title: Return list containing indices of each element in a vector
body: <p>I have a vector in R containing repetitive elements</p>
  
  <pre><code>a&lt;-c("A","A","A","B","B","C","A")
  </code></pre>
  
  <p>And I would like to know the most efficient way to transform it in a list where each element is the key, and its positions in the original vector are the values:</p>
  
  <pre><code>l&lt;-list(A=c(1,2,3,7),B=c(4,5),C=c(6))
  l
  $A
  [1] 1 2 3 7
  $B
  [1] 4 5
  $C
  [1] 6
  </code></pre>