How to make data into groups and then into subgroups

step1: I wanna group the dataset into [0,0.5Y),[0.5Y,2Y),[2Y,4Y]

step2: make data in each group into smaller subgroups.

For example:

[0,0.5Y): [0,0.1Y),[0.1,0.2Y),[0.2,0.3Y),[0.3,0.4Y),[0.4,0.5Y)

[0.5Y,2Y):[0.5,1Y),[1,1.5Y),[1.5,2Y)

[2Y,4Y):[2,3Y),[3,4Y)

step3: see the distribution of each groups and each subgroup

step4: substract the first calue in each smaller subgroup

For step1&2, since it requires to group data twice, and the range of smaller subgroups are not the same, I'm quiet confused about how to make my code in the most efficient way.

For step 3, I think I can create a dataset consisting of major groups and the other one consisting of all the subgroups, and then plot two scatter plots seperately.

```
dataframe<-df <- data.frame(
maturity=c("0.24Y","0.6Y","0.7Y","0.9Y","0.98Y","3Y","3.5Y","2.9Y","0.32Y"),
price = c(2,4,3,6,23,4,7,2,7))
```