title: How do restructure the trip data to prepare a link data using spread and gather functions in R?
body: <p>I have a trip data set as follows:</p>
  
  <pre><code>df &lt;- data.frame(user =c("P001", "P001", "P002"), tripID = c("tid1", "tid2", "tid3"), mode =c("bus", "train", "taxi"), Origin = c("Westmead", "Redfan", "Westmead"), Destination = c("Redfan", "Darlington", "Strathfield"), depart_dt = c("8:00", "8:30", "8:45") )
  </code></pre>
  
  <p>I need to restructure the above data using probably spread() and gather() functions from tidyr to prepare a link trip data as follows:</p>
  
  <pre><code>df_new &lt;- data.frame(user=c("P001", "P002"), tripID = c("newtid1", "newtid2"), mode = c("bus + train", "taxi"), Origin = c("Westmead", "Westmead" ), Destination = c("Darlington", "Strathfield"), depart_dt = c("8:00", "8:45"))
  </code></pre>
  
  <p>I am a new bee in R. Can anyone help me here?</p>
  
  <p>Many thanks in advance.</p>