生成一天的时间序列,在 R 中有微小的差异 [英] Generate time sequence of a day with a minute difference in R

查看:25
本文介绍了生成一天的时间序列,在 R 中有微小的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 R 之类的微小差异生成一天的时间序列

I want to generate time sequence of a day by a minute difference using R like

00:00, 00:01, 00:02, ..., 23:59

同样,我使用 xts 包含以下代码行的包

For the same, I am using timeBasedSeq function of xts package with following lines of code

timerange1<- paste('T00:00','/','T23:59',' 12:00',sep="")
timeBasedSeq(timerange1)

但是,我无法用这个生成序列.另外,我不明白 12:00 在第一行代码中的含义,它与分钟、小时或秒有何关系.

But, I am not able to generate the sequence with this. Also, I do not understand what 12:00 mean in first line of code, i.e., how does it relate to minutes or hours or seconds.

任何帮助将不胜感激.

推荐答案

您不遵守所需的格式:CCYYMMDD HHMMSS,在您的情况下为 CCYYMMDD HHMM.试试:

You don't respect the required format: CCYYMMDD HHMMSS, in your case CCYYMMDD HHMM. Try:

library(xts)
timerange1 <- "20160106 0000/20160106 2359"
seqMinute <- format(timeBasedSeq(timerange1), "%H:%M")
length(seqMinute)
# [1] 1440
range(seqMinute)
# [1] "00:00" "23:59"

这篇关于生成一天的时间序列,在 R 中有微小的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆