R中的每小时日期序列

问题描述:

我正在尝试每隔一小时生成一系列日期.例如,我尝试了以下操作:

I am trying to produce a sequence of dates at hourly intervals. As an example I tried the following:

> seq(as.Date("1912-02-24 23:00:00"), as.Date("1912-02-25 08:32:00"), by="hour")

会产生错误,但它在 by= 年、月、日时工作正常.

which produces an error, yet it works fine for by= year, month, day.

seq.POSIXt {base} 的文档指出它应该在小时、秒、分钟等时间内工作,但所有这些都会产生错误.

The documentation for seq.POSIXt {base} states that it should work for hour, sec, min, etc, yet all of these produce an error.

> ?seq.POSIXt

提前致谢.

好吧,你自己不给答案 ;-)

Well, don't you give the answer yourself ;-)

关于:

seq(as.POSIXct("1912-02-24 23:00:00"), as.POSIXct("1912-02-25 08:32:00"), by="hour")

(也适用于 as.POSIXlt).