x1=c(1,1,1,1,1,2,2,1,1,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2)
A=data.frame(x1)
library(dplyr)
A=A %>%
mutate(Day = (row_number()-1) %/% 7 + 1)
A
The result with this mutated above is different from what I would like.
## this is the result I would like to have
x1 Day
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1
6 2 1
7 2 1
8 1 2
9 1 2
10 2 2
11 2 2
12 2 2
13 2 2
14 2 2
15 2 2
16 1 3
17 1 3
18 1 3
19 1 3
20 1 3
21 2 3
22 2 3
23 2 3
24 2 3