title: Replace column values for subset of rows using a vector
body: <p>I am trying to replace the values of a column (cluster) for a subset of rows (value &lt; 6) within a data frame with the values of a vector.</p>
  
  <pre><code>df &lt;- structure(list(value = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), cluster = c(0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0)), .Names = c("value", "cluster"), row.names = c(NA, 
  -10L), class = "data.frame")
  
  new_cluster &lt;- structure(list(cluster = c(1, 1, 2, 2, 2)), .Names = "cluster", row.names = c(NA, 
  -5L), class = "data.frame")
  </code></pre>
  
  <p>I know how to change the column values for a subset of rows to one value:</p>
  
  <pre><code>df[df$value&lt;6,]$cluster &lt;- 1
  </code></pre>
  
  <p>However I would like to reference a vector (new_cluster) rather than a single value. I've tried the below which doesn't give the desired output however I'm sure there must a simple way to do this.</p>
  
  <pre><code>df[df$value&lt;6,]$cluster &lt;- new_cluster
  </code></pre>
  
  <p>I'm trying to achieve the below data frame:</p>
  
  <pre><code>     value       cluster
  1      1             1
  2      2             1
  3      3             2
  4      4             2
  5      5             2
  6      6             0
  7      7             0
  8      8             0
  9      9             0
  10    10             0
  </code></pre>