title: Proper preprocessing in R
body: <p>I have a  dataset like this</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>FID</th>
  <th>osmid</th>
  <th>s</th>
  <th>e</th>
  <th>seg_length</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>4999</td>
  <td>733</td>
  <td>99</td>
  <td>7.7</td>
  </tr>
  <tr>
  <td>1</td>
  <td>566</td>
  <td>733</td>
  <td>33</td>
  <td>3.2</td>
  </tr>
  <tr>
  <td>2</td>
  <td>499</td>
  <td>713</td>
  <td>96</td>
  <td>7.7</td>
  </tr>
  <tr>
  <td>3</td>
  <td>56</td>
  <td>783</td>
  <td>32</td>
  <td>3.5</td>
  </tr>
  <tr>
  <td>4</td>
  <td>409</td>
  <td>783</td>
  <td>98</td>
  <td>7.6</td>
  </tr>
  <tr>
  <td>5</td>
  <td>516</td>
  <td>736</td>
  <td>38</td>
  <td>3.5</td>
  </tr>
  <tr>
  <td>6</td>
  <td>459</td>
  <td>739</td>
  <td>98</td>
  <td>7.7</td>
  </tr>
  <tr>
  <td>7</td>
  <td>526</td>
  <td>731</td>
  <td>33</td>
  <td>3.2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>s stands for starting work and e for ending point. Some FID share the same start and end point. I want to keep only one start and end point for every point so when two starting point are shared I want to keep only these with the shortest seg_length. I could'nt find a good code for that.
  Every end and start point should only have one unique value.</p>
  <p>For example FID 0 and 1 share the same starting point and in the new dataset only FID 1 should be there. Also FID 4 and FID 6 share the same end point and in the new dataset only 4 should be there.</p>