title: updating column in one dataframe with value from another dataframe based on matching values
body: <p>I have a data frame "z"</p>
  
  <pre><code>   letter color
  1       a     0
  2       e     0
  3       b     0
  4       b     0
  5       d     0
  6       d     0
  7       a     0
  8       b     0
  9       c     0
  10      d     0
  11      c     0
  12      c     0
  13      c     0
  14      c     0
  15      e     0
  16      e     0
  17      a     0
  18      d     0
  19      e     0
  20      b     0
  </code></pre>
  
  <p>and another data frame "y"</p>
  
  <pre><code>  letter color
  1      a   red
  2      b  blue
  3      c green
  </code></pre>
  
  <p>when the letter in z matches with a letter in y  I would like to append the color from y into the corresponding color field in z but I do not want to remove any values from z.  If a match doesn't occur, z$color should remain unchanged. I used"0" as a place holder in z$color, this could be text instead.  </p>
  
  <p>I've been attempting things for loops, the match() command and statements with %in% but I'm not quite achieving the results I'm after.</p>
  
  <p>Any ideas?</p>
  
  <p>This is the code I used for the data frames</p>
  
  <pre><code>set.seed(3)
  z=data.frame(sample(c("a","b","c","d","e"),20,replace=T))
  names(z)="letter"
  z$color=rep(0,dim(z)[1])
  z
  
  y1=c("a","b","c")
  y2=c("red","blue","green")
  y=data.frame(cbind(y1,y2))
  names(y)=c("letter","color")
  y
  </code></pre>