I want to achieve mentioned output for the below input.
Input:
| Extent | Date | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|---|---|
| 2 | 10-Mar-22 | a | b | c | d | e | f | g |
| 8 | 08-Mar-22 | A | B | C | D | E | F | G |
Code snippet for input:
input_df <- structure(list(extent = c(2,8), Date = c("10-Mar-22","08-Mar-22"),Sun = c("a", "A"), Mon = c("b", "B"), Tue = c("c", "C"), Wed = c("d", "D"), Thu = c("e", "E"), Fri = c("f", "F"), Sat = c("g", "G")), row.names = c(NA, -2L), class = "data.frame")
Rules to achieve the output:
- The maximum of extent defines the no. of columns in output
- Rows of input = Rows of output
- Day of the week of the Date in input indicates the starting point to copy the data into output
- Extent tells how many cells to copy
- Once data copying reaches Sat, it should start back from Sun until the Extent is satisfied
Output:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|
| e | f | ||||||
| C | D | E | F | G | A | B | C |
Please help me with a solution which uses vector operation.