title: For loop in R with key value
body: <p>What is the equivalent way in R to </p>
  
  <pre><code>foreach ($arr as $key =&gt; $value) {
      echo "Key: $key; Value: $value&lt;br /&gt;\n";
  }
  </code></pre>
  
  <p>that means</p>
  
  <pre><code>arr&lt;-c(a=1,b=2,c=3)
  key&lt;-names(arr)
  val&lt;-arr
  for(i in 1:length(arr)){
   print(paste(key[i],val[i]))
  }
  </code></pre>