The data frame looks like this (the dots are supposed to be vertical dots):
Class IncreasingNumber
"A" 3 <- row 1
"A" 5 <- row 2
... ...
"A" 20 <-row 31
"B" 1
"B" 2
... ...
"B" 41 <- row 63
"C" 1
......
There are 20 different classes. The number of rows within each class equals 31.
What I wan to do is quite simple. For each class, I want to insert 3 new rows between all rows. So, we want to insert 3 new rows between row 1 and row 2, and yet 3 others in between row 2 and row 3, all the way up to 3 three new rows between row 30 and 31. But NO new rows between row 31 and 32, since these belong to a different class.
We want to do this for every class.
The three rows which we insert has the same Class as its surrounding rows, and the IncreasingNumber value for those three rows are just the 3 equally spaced points within the IncreasingNumber values for the surrounding points.
For example, for the first class, and for the first three rows to be inserted between row 1 and row 2, we see that the IncreasingNumbers are 3 and 5.
Therefore, the first value for the first row that we insert should be 3.5. The next value should be 4. The third value should be 4.5.
So we should get something like this for the first two classes:
Class IncreasingNumber
"A" 3
"A" 3.5 <- new row
"A" 4 <- new row
"A" 4.5 <- new row
"A" 5
... ...
"A" 20
"B" 1
"B" 1.25 <- new row
"B" 1.5 <- new row
"B" 1.75 <- new row
"B" 2
... ...
"B" 41
"C" 1