Grouping data into ranges in R
- by Maddy
supposing i have a data frame in R that has names of students in one column and their marks in another column. these marks range from 20 to 100.
> mydata
id name marks gender
1 a1 56 female
2 a2 37 male
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.