title: long table to wide table in R
body: <pre><code>df = data.frame(record = c(20200525,20200608,20200608,20200615,20200615,20200622,20200622,20200701,20200701,20200706,20200706,20200713,20200713,20200727,20200727,20200803), team = c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;C&quot;,&quot;C&quot;,&quot;D&quot;,&quot;D&quot;,&quot;E&quot;,&quot;E&quot;,&quot;F&quot;,&quot;F&quot;,&quot;G&quot;,&quot;G&quot;,&quot;H&quot;,&quot;H&quot;))
  </code></pre>
  <p>Want to use df$record min as value of column S, max as value of column E in each team.
  and would be looking for an answer like this:</p>
  <p><a href="https://i.stack.imgur.com/1iIEe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1iIEe.png" alt="enter image description here" /></a></p>
  <p>I tried using:</p>
  <pre><code>df %&gt;% mutate(S = top_n(1, record) ,E = top_n(-1, record))
  </code></pre>
  <p>and it gave me Error...
  Thanks for any help.</p>