title: How to transpose column and group at the same time
body: <p>I have a dataset as follows:</p>
  
  <pre><code>Pt    EVENT
  123    GGG
  123    Nor
  123    tre
  144    GGG
  1667   tre
  1667   Nor
  1667   tre
  </code></pre>
  
  <p>I am trying to prepare the data eventually for a Sankey diagram and in order to do this I need to get the data into the following shape</p>
  
  <pre><code>Pt    
  123   GGG      Nor   tre
  144   GGG
  1667  tre      Nor   tre
  </code></pre>
  
  <p>And then eventually I think into a source, target, value format as follows:</p>
  
  <pre><code>source    target   value
   GGG        Nor       1
   GGG                  1
   tre        tre       1
   Nor        tre       2
  </code></pre>
  
  <p>The part I don't understand is how to get from the original dataset to the second one. I thought I might be able to do it with dplyr but no joy:</p>
  
  <pre><code>  Sankey&lt;-EndoSubset %&gt;%
        group_by(Pt) %&gt;% 
        select(t(EVENT))
  </code></pre>