[R] seq

Thomas Lumley tlumley at u.washington.edu
Mon Apr 10 20:15:56 CEST 2006


On Mon, 10 Apr 2006, Omar Lakkis wrote:

> Can someone, please, help explain to me why the following two calls
> return the same set:
>
>>  seq(from=as.POSIXlt('2005-12-4'), to=as.POSIXlt('2006-4-2'), by='weeks')
> [1] "2005-12-04 EST" "2005-12-11 EST" "2005-12-18 EST" "2005-12-25 EST"
> [5] "2006-01-01 EST" "2006-01-08 EST" "2006-01-15 EST" "2006-01-22 EST"
> [9] "2006-01-29 EST" "2006-02-05 EST" "2006-02-12 EST" "2006-02-19 EST"
> [13] "2006-02-26 EST" "2006-03-05 EST" "2006-03-12 EST" "2006-03-19 EST"
> [17] "2006-03-26 EST" "2006-04-02 EST"
>
>>  seq(from=as.POSIXlt('2005-12-4'), to=as.POSIXlt('2006-4-9'), by='weeks')
> [1] "2005-12-04 EST" "2005-12-11 EST" "2005-12-18 EST" "2005-12-25 EST"
> [5] "2006-01-01 EST" "2006-01-08 EST" "2006-01-15 EST" "2006-01-22 EST"
> [9] "2006-01-29 EST" "2006-02-05 EST" "2006-02-12 EST" "2006-02-19 EST"
> [13] "2006-02-26 EST" "2006-03-05 EST" "2006-03-12 EST" "2006-03-19 EST"
> [17] "2006-03-26 EST" "2006-04-02 EST"
>
>
>> seq
> function (...)
> UseMethod("seq")
> <environment: namespace:base>
>
> I am using R 2.2.1 on linux.
> Why isn't "2006-04-09" in the response of the second call?
>

It is because 2006-4-9 happened less than a week after 2006-4-2, because 
2006-4-2 was only 23 hours long in your time zone.  Use Date if you just 
want dates, not times.

 	-thomas




More information about the R-help mailing list