R刻度数据:将日期和时间合并到一个对象中 [英] R tick data : merging date and time into a single object

查看:17
本文介绍了R刻度数据:将日期和时间合并到一个对象中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 R 处理刻度数据,我想将日期和时间合并到一个对象中,因为我需要获得一个精确的时间对象来计算我的数据的一些统计信息.这是我的数据的样子:

I'm currently working in tick data with R and I would like to merge date and time into a single object as I need to get a precise time object to compute some statistics on my data. Here is how my data looks like:

               date       time      price flag    exchange
2   XXH10   2010-02-02   08:00:03   2787 1824        E
3   XXH10   2010-02-02   08:00:04   2786    3        E
4   XXH10   2010-02-02   08:00:04   2787    6        E
5   XXH10   2010-02-02   08:00:04   2787    1        E
6   XXH10   2010-02-02   08:00:04   2787    1        E

基本上,我想将日期"和时间"列合并为一个.

Basically, I would like to merge the columns "date" and "time" into a single one.

推荐答案

as.POSIXct创建一个datetime对象:

as.POSIXct(paste(x$date, x$time), format="%Y-%m-%d %H:%M:%S")
[1] "2010-02-02 08:00:03 GMT" "2010-02-02 08:00:04 GMT" "2010-02-02 08:00:04 GMT"
[4] "2010-02-02 08:00:04 GMT" "2010-02-02 08:00:04 GMT"

这篇关于R刻度数据:将日期和时间合并到一个对象中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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