I have a df with a single column (col1)
df <- data.frame(col1 = c(96, 56, 53, 63, 70, 65, 72,
111, 65, 58, 59, 74, 57, 70,
89, 60, 60, 52, 65, 58, 84,
54, 55, 51, 72))
I want to take the average of 7 values at a time and move a value down at a time to get a table like this below. So each value in week_avg
is average of the last 7 values of the col1
col1 week_avg
96
56
53
63
70
65
72 68
111 70
65 71
58 72
59 72
74 72
57 71
70 71
89 67
60 67
60 67
52 66
65 65
58 65
84 67
54 62
55 61
51 60
72 63