title: R: fill a new column in a data frame with a value by matching variables in reverse
body: <p>I apologize for the title of this question. I can't figure out how a good way to briefly describe what I want to do.</p>
  
  <p>I have something like this, with >8000 rows:</p>
  
  <pre><code>x  y value_xy
  A  B   7 
  A  C   2 
  B  A   3
  B  C   6 
  C  A   2
  C  B   1
  </code></pre>
  
  <p>I want to create a new column, value_yx, that looks like this:</p>
  
  <pre><code>x  y value_xy value_yx
  A  B   7         3 
  A  C   2         2  
  B  A   3         7
  B  C   1         1
  C  A   2         2
  C  B   1         1
  </code></pre>
  
  <p>For each value of x and y, I want to have a new column that finds the value of y to x (as y appears later in the x column). Sometimes these values are equal, other times they aren't.</p>
  
  <p>I have explored using for loops, ave(), and several other functions, but I haven't been able to make it work.</p>