I'd like to convert original date as follows:

[1] 201212300900 201212300951 201212301051 201212301151 201212301200 201212301251    
[2] 201212301351 201212301451 201212301500 201212301551 201212301651 201212301751    
[3] 201212301800 201212301851 201212301951 201212302051 201212302100 201212302151    
[4] 201212302251 201212302351 201212310000 201212310051 201212310151 201212310251    
[5] 201212310300 201212310351 201212310451 201212310459 201212310551 201212310600

into this format: %Y-%m-%d %H:%M

and then, aggregate those date by hour knowing that they were recorded as different intervals.

For example 2012-12-30 09:00 + 2012-12-30 09:51 = 2012-12-30 09

有帮助吗?

解决方案

Try something like

dts <- c("201212300900", "201212300951", "201212301051", "201212301151", 
         "201212301200", "201212301251")
dts <- strptime(dts, format="%Y%m%d%H%M")
trunc(dts, "hours")

Hope it helps

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top