Can someone explain what the second d$year is not 1?
> d = as.POSIXlt("1900-01-01")
> d$year
[1] 0
> d$mon = d$mon + 12
> d
[1] "1901-01-01"
> d$year
[1] 0
>
Contrast with this:
> d = as.POSIXlt("1900-01-01")
> d
[1] "1900-01-01"
> d$year
[1] 0
> d$year = d$year + 1
> d
[1] "1901-01-01"
> d$year
[1] 1
>
POSIXltobjects are lists. You changed themonelement of the list. That does not change theyearelement of the list.If you want your change to alter any/all of the other list elements, convert it to
POSIXctthen back toPOSIXlt.