title: R - Cutting a data frame by two columns
body: <p>I am trying to categorise location points according to their distance and bearing from the first point in a data frame. This code is working, however it only checks the distances from <code>df$dist</code> column. </p>
  
  <pre><code>df$circle_id = cut(df$dist, seq(0,41000000,1000), labels=FALSE, include.lowest=TRUE)
  </code></pre>
  
  <p>What I want to do is also check if the bearing of points is the same, and only then they can be put in the same category. Bearings are stored in <code>df$bearing</code>.</p>
  
  <p>Simply put, I need to combine these two operations into one:</p>
  
  <pre><code>df$circle_id = cut(df$dist, seq(0,41000000,1000), include.lowest=TRUE)
  df$circle_id = cut(df$bearing, seq(-180,180,10), labels=FALSE, include.lowest=TRUE)
  </code></pre>
  
  <p>Sample data frame:</p>
  
  <pre><code> latitude longitude sensor_time circle_id segment_id  weight        dist    bearing
  1 48.15144  17.07569  1447149703         1          1      2    0.000000 -180.00000
  3 48.15404  17.07452  1447149743         3          1      1  302.422843  163.22826
  4 48.15277  17.07514  1447149762         2          1      1  153.179367  164.50437
  5 48.15208  17.07538  1447149771         1          1      1   74.666669  161.91792
  6 48.15461  17.07560  1447149773         3          1      3  353.106770  178.87100
  9 48.15139  17.07562  1447149811         1          1      2    7.828957   43.83916
  </code></pre>
  
  <p>Any help is appreciated, 
  thank you</p>