[R] order list of date (bug?)
wdunlap at tibco.com
Thu Jan 26 20:22:47 CET 2017
The R bug I mentioned was not that
as.POSIXlt("2016-03-27 02:30", format="%Y-%m-%d %H:%M", tz="CET")
returned an NA. That seems reasonable since there was no such time.
The bug is that the POSIXlt object prints in an odd format (leaving
off the time zone/daylight/standard time string) instead of printing
an NA. This made it hard for you to see the problem.
Using tz="GMT" or "UTC" will give 'solar' time England.
tz="Etc/GMT-1" will give 'solar' time in central Europe.
On Thu, Jan 26, 2017 at 10:46 AM, rob vech <rob.vech87 at gmail.com> wrote:
> Hi William,
> asking to the r-devel list I resolved the problem! It depends from the
> timezone (tz param) that I didn't specified and so R automatically uses my
> local time and considers also the daylight saving time (that comes at 2:00
> at my position).
> As my dates are in solar time, I specified the time zone as "GMT" and it
> Here a simple example:
> df = data.frame(DateTime = c(
> '2016-12-21 10:34:54',
> '2016-12-21 11:04:54',
> '2016-12-21 11:34:54',
> '2016-03-27 02:05:50',
> '2016-03-27 02:35:50',
> '2016-12-21 12:04:54',
> '2016-12-21 12:34:54'
> df$DateTime = as.POSIXlt(strptime(df$DateTime,
> format='%Y-%m-%d %H:%M:%S',
> ord = order(as.numeric(strptime(df$DateTime, format='%Y-%m-%d %H:%M:%S',
> df.ord = df[ord,1]
More information about the R-help