title: R: add column based on existing column relationship
body: <p>I have a data frame that I'm using to tabularly represent a directed graph relationship. Right now I am considering three nodes at a time. I have the relation between node1 and node2, and the relation between node2 and node3, each of which have corresponding edge weights. In rare cases there is a relationship between node1 and node3, but I am having trouble isolating it.
  In essence, I have A -> B, and B -> C, and want to find A -> C.
  Here is an example of the data frame.</p>
  
  <pre><code>df
        node1    node2   weight1     node2_a     node3   weight2
         5         2        .2          2         7        .3
         10        20       .4         20         30       .6
         10        30       .3         30         8        .3
  </code></pre>
  
  <p>So, I would essentially like to have another three columns, which would read like this</p>
  
  <pre><code>new_df
        node1    node2   weight1     node2_a     node3   weight2   node1.a     node3.a     weight3
         5         2        .2          2         7        .3         na          na          na
         10        20       .4         20         30       .6         10          30          .3
         10        30       .3         30         8        .3         na          na         na
  </code></pre>
  
  <p>I understand there may be better ways to do this, but I'm curious how I can make it work like this. Thanks, if this is unclear I am happy to explain further.</p>