如何拆分日期&时间观察 [英] How To Split a Date & Time Observation
本文介绍了如何拆分日期&时间观察的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下时间序列观察,
10/08/2015 02:31:04.450
- 我想分割日期和时间来分隔列。
- 我需要及时缩短毫秒吗?如果是这样,
我一直在看,数据表
, lubridate
来尝试弄清楚。我查看了 XTS
,但这似乎更加集中于日期。
R中是否有任何现有的软件包允许这种拆分?我会使用什么样的论据。
任何帮助都将不胜感激。
解决方案
使用 data.table
非常简单: p>
require(data.table)
x< - 10/08/2015 02:31:04.450
IDateTime(strptime(x,%d /%m /%Y%H:%M:%OS))
给你以下 data.table
idate itime
1:2015-08-10 02:31:04
I am just learning R and have come up against this.
I have the below time series observations,
10/08/2015 02:31:04.450
- I want to split the date and the time to separate columns.
- Do i need need to round the Milliseconds in time? if so how.
I have been looking at, data table
, lubridate
to try and figure it out. I looked at XTS
but that seems to be more orientated to aggregation of dates.
Are they any existing packages in R that allows for this splitting? and what sort of argument would I use.
Any help would be much appreciated.
解决方案
Using data.table
it is very straight forward:
require(data.table)
x <- "10/08/2015 02:31:04.450"
IDateTime(strptime(x, "%d/%m/%Y %H:%M:%OS"))
gives you the following data.table
idate itime
1: 2015-08-10 02:31:04
这篇关于如何拆分日期&时间观察的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文