2013-07-11 44 views
1

有没有办法在R中生成只有时间的序列?我不想使用日期;我需要每隔5分钟从12:00:00至13:00:00发生所有时间。仅生成时间序列

seq()不会在这里工作:

interval = min * 60 
seq(from = times('12:00:00'), to = times('13:00:00'), by = interval) 
+0

可能重复[在R中创建特定的日期/时间序列](http://stackoverflow.com/question s/14009301 /创建特定的日期时间在r) – Thomas

+0

另一个可能的重复:[生成日期序列](http://stackoverflow.com/questions/14706330/generating-sequence-日期?rq = 1) – Thomas

+0

@Thomas问题是关于仅限时间的系列。没有日期。 –

回答

4

你的代码的工作几乎一字不差与代上:

> library(chron) 
> min <- 5 
> interval <- min/(60 * 24) 
> seq(from = times('12:00:00'), to = times('13:00:00'), by = interval) 
[1] 12:00:00 12:05:00 12:10:00 12:15:00 12:20:00 12:25:00 12:30:00 12:35:00 
[9] 12:40:00 12:45:00 12:50:00 12:55:00 13:00:00 

或者interval可以这样指定:中

interval <- times("00:05:00")