title: Grouping data into ranges in R
body: <p>Suppose I have a data frame in <strong>R</strong> that has names of students in one column and their marks in another column. These marks range from 20 to 100.</p>
  
  <pre><code>&gt; mydata  
  id  name   marks gender  
  1   a1    56     female  
  2   a2    37      male  
  </code></pre>
  
  <p>I want to divide the student into groups, based on the criteria of obtained marks, so that difference between marks in each group should be more than 10. I tried to use the function table, which gives the number of students in each range from say 20-30, 30-40, but I want it to pick those students that have marks in a given range and put all their information together in a group. Any help is appreciated.</p>