This has to do with the way the function week
is written in the package:
> week()
function (x)
yday(x)%/%7 + 1
In your case, for January 7, 2012:
x = as.POSIXlt("2012-1-7")
yday(x) = 1
Then:
week(x) = (1%/%7) + 1 = 2
For it to work as you wish, try this:
x=seq(as.POSIXlt("2012-1-1", tz = "UCT"), as.POSIXlt("2012-1-20", tz = "UTC"), by="day")
cbind(as.character(x), (yday(x)-1)%/%7+1)
You get the following output:
# [,1] [,2]
# [1,] "2012-01-01" "1"
# [2,] "2012-01-02" "1"
# [3,] "2012-01-03" "1"
# [4,] "2012-01-04" "1"
# [5,] "2012-01-05" "1"
# [6,] "2012-01-06" "1"
# [7,] "2012-01-07" "1" <<<
# [8,] "2012-01-08" "2"
# [9,] "2012-01-09" "2"
#[10,] "2012-01-10" "2"
#[11,] "2012-01-11" "2"
#[12,] "2012-01-12" "2"
#[13,] "2012-01-13" "2"
#[14,] "2012-01-14" "2"
#[15,] "2012-01-15" "3"
#[16,] "2012-01-16" "3"
#[17,] "2012-01-17" "3"
#[18,] "2012-01-18" "3"
#[19,] "2012-01-19" "3"
#[20,] "2012-01-20" "3"