如何解析R中的毫秒? [英] How to parse milliseconds in R?

查看:414
本文介绍了如何解析R中的毫秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用strptime或任何其他函数来解析R中的毫秒的时间戳?

How do I use strptime or any other functions to parse timestamps with milliseconds in R?

> time[1]
[1] "2010-01-15 13:55:23.975"
> strptime(time[1], format="%Y-%m-%d %H:%M:%S.%f")
[1] NA
> strptime(time[1], format="%Y-%m-%d %H:%M:%S")
[1] "2010-01-15 13:55:23"`


推荐答案

感谢?strptime 帮助文件(示例更改为您的值):

Courtesy of the ?strptime help file (with the example changed to your value):

 z <- strptime("2010-01-15 13:55:23.975", "%Y-%m-%d %H:%M:%OS")
 z # prints without fractional seconds
 op <- options(digits.secs=3)
 z
 options(op) #reset options

这篇关于如何解析R中的毫秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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