title: For loop: replacement has one row more than data
body: <p>I am an beginner in R and have a problem. Any help would really be appreciated!
  When I apply the for loop in the following (simplified) case, I get an error message saying "replacement has 5 rows, data has 4"</p>
  
  <pre><code>Country &lt;- c("Germany", "France", "Italy", "Spain")
  Unemploy &lt;- c(2, 3, 4, 10)
  Growth &lt;- c(2, 7, 6, 9)
  data &lt;- data.frame(Country, Unemploy, Growth)
  
  for (i in data$Country) {
       if (identical(data$Country[i], "France")) {
            data$Growth[i] &lt;- "5"
       } else {
            data$Growth[i] &lt;- "2"
       }
  }
  </code></pre>
  
  <p>Following message given out:</p>
  
  <pre><code>Error in `$&lt;-.data.frame`(`*tmp*`, "Growth", value = c("2", "2", "2",  : 
  replacement has 5 rows, data has 4
  </code></pre>