I have the data.frame with the last 12 months values for 3 observations. There is a Date variable corresponging to the month.m0 (the most recent), and then the values goes backward in time substracting one month each time:

---

```
date <- c("2017-01-01", "2016-12-01", "2016-10-01")
month.m0 <- c(1, 2, 3)
month.m1 <- c(4, 5, 6)
month.m2 <- c(7, 8, 9)
month.m3 <- c(10, 11, 12)
month.m4 <- c(13, 14, 15)
month.m5 <- c(16, 17, 18)
month.m6 <- c(19, 20, 21)
month.m7 <- c(22, 23, 24)
month.m8 <- c(25, 26, 27)
month.m9 <- c(28, 29, 30)
month.m10 <- c(31, 32, 33)
month.m11 <- c(34, 35, 36)

df <- data.frame(date, month.m0, month.m1, month.m2, month.m3, month.m4, month.m5, month.m6, month.m7, month.m8, month.m9, month.m10, month.m11)

```

The input will be:

```
        date month.m0 month.m1 month.m2 month.m3 month.m4 month.m5 month.m6 month.m7 month.m8 month.m9 month.m10 month.m11
1 2017-01-01        1        4        7       10       13       16       19       22       25       28        31        34
2 2016-12-01        2        5        8       11       14       17       20       23       26       29        32        35
3 2016-10-01        3        6        9       12       15       18       21       24       27       30        33        36

```

The problem here is that I don't know the real month of each observation, because the numeration is ordinal and depends on the date variable.

The initial value (month.m0) correspond for the first row to the month january, becasue the date is january (it doesnt matter the day or the year). For the second row, the date is indicating that the **month.m0** corresponds to december, and the third corresponds to october. Then, **month.m1** is the **((month(Date) - months(1))** value, the month.m2 corresponds to **(month(Date) - months(2))** and so on, going back in time from the initial value

EDITED OUTPUT:

I was trying to assign each value to the real month, so the output would be:

```
        date Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1 2017-01-01   1  34  31  28  25  22  19  16  13  10   7   4
2 2016-12-01  35  32  29  26  23  20  17  14  11   8   5   2
3 2016-10-01  30  27  24  21  18  15  12   9   6   3  36  33

```

It's easy to assign the first month for each observation, but then it complicates when going backwards in time.