简体   繁体   English

生成R中任何频率的时间序列

[英]Generate time-series of any frequency in R

I used to generate time-series in R using xts package as 我曾经使用xts包在R生成时间序列

library(xts)
seq <- timeBasedSeq('2015-06-01/2015-06-05 23')
z <- xts(1:length(seq),seq)

After a bit of tweaks, I find it easy to generate data at a default rate of 1 hour or 1 minute or 1 second. 经过一些调整后,我发现以1小时或1分钟或1秒的默认速率生成数据很容易。 Reading the help page of ?timeBasedseq does not clearly mention how to generate data at other frequncies. 阅读?timeBasedseq的帮助页面没有明确提到如何在其他频率上生成数据。 Say, I want to generate data at 10 minutes rate. 说,我想以10分钟的速率生成数据。 Where Should I mention M (minutes) and 10 in the said command to generate 10 minutes data. 我应该在上述命令中何处提及M (分钟)和10以生成10分钟数据。 Option M is mentioned in the help pages. 帮助页面中提到了选项M

This isn't currently possible. 目前这不可行。 The "by" value is essentially hard-coded at 1 unit. “by”值基本上是1个单位的硬编码。 It should be possible to patch the code so you can specify the "by" component as something like "10M" for 10-minutes, since seq.POSIXct would accept a by = "10 mins" value. 应该可以对代码进行修补,以便您可以在10分钟内将“ by”组件指定为类似于"10M"的内容,因为seq.POSIXct将接受by = "10 mins"值。

If you want, you can create an issue for this feature request and we can discuss details of what this patch should include. 如果需要,您可以为此功能请求创建问题,我们可以讨论此补丁应包括的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM