R-将时间序列拆分为仅时间段 [英] R - Split time series into time-only bins

查看:51
本文介绍了R-将时间序列拆分为仅时间段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个时间序列,以适当的POSIX时间,我想根据一天中的时间进行分类.我很容易将时间归类为几个小时,但是这些时间是特定于日期的(例如: 2016-05-15 00:00:00 2016-05-16 00:00:00 被视为不同的bin).

I've a time series, in proper POSIX time, that I'd like to bin according only to time of day. I'm well able to bin things in, say, hours—but these hours are date-specific (for example: 2016-05-15 00:00:00 and 2016-05-16 00:00:00 are considered different bins).

我想将所有 00:00:00-00:59:59 都集中到一个容器中,所有 01:00:00-01:59:59 放入另一个垃圾箱等,但是我找不到不包括日期的方法.

I'd like to lump all 00:00:00 - 00:59:59 into one bin, all 01:00:00 - 01:59:59 into another bin, etc., but I can't find a means of doing this without including the date.

有人对如何执行此操作有任何想法吗?我愚弄了 cut lubridate 都没用.

Does anyone have any idea as to how to do this? I've fooled around with cut and lubridate mostly to no avail.

推荐答案

删除日期并仅处理时间部分?

Drop the date and deal only with the time component?

format(tt, "%H:%M:%S")

将时间成分提取为字符串,但可以对其进行修改以进一步将其转换为装仓代码处理的任何格式.或者,在合并之前将日期设置为相同.

extracts the time component into a string, but it can be modified to further convert to any format your binning code handles. Alternatively, make the date the same prior to binning.

这篇关于R-将时间序列拆分为仅时间段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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