title: How to get index in a loop in R
body: <p>I have a vector of character type which has all the list of names.</p>
  
  <p>So I'm looping through each name and peforming some actions. This loop is not based on the index/length (and I want to keep it this way).</p>
  
  <p>However, if I want to access the index value in the loop how do I get it.</p>
  
  <p>Ex:</p>
  
  <pre><code>names &lt;- c("name1", "name2")
  
  for(name in names){
  
  #do something
  print(name)
  
  #here how would I get the index number? like 1, 2 etc?
  
  }
  </code></pre>