[英]Group time-series observations in R
I have a time seriesAnd I have values from 15 to 15 minutes (so I have 4 values per hour) but I am trying to reduce the data for clustering analysis. 我有一个时间序列,我的值在15到15分钟之间(所以我每小时有4个值),但是我正在尝试减少用于聚类分析的数据。
I want to check if I can group per hour in R Software. 我想检查是否可以每小时在R Software中分组。 So I think I need to check for similarities with some kind of statiscal test.
因此,我认为我需要通过某种状态测试来检查相似性。
Can someone help me? 有人能帮我吗?
For this general type of a problem you can use the xts package: 对于这种一般类型的问题,可以使用xts包:
library(xts)
# convert your data to xts object
your.data.xts <- xts(data$value,
as.POSIXct(data$time))
# aggregate by hour
hourly.apply(dat.xts,sum)
You could also use the base aggregate()
function or period.apply()
https://www.rdocumentation.org/packages/rts/versions/1.0-12/topics/period.apply 您还可以使用基本的
aggregate()
函数或period.apply()
https://www.rdocumentation.org/packages/rts/versions/1.0-12/topics/period.apply
In the future, please provide a reproducible example (with your data) when asking a question. 将来,在提出问题时,请提供一个可复制的示例(连同您的数据)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.