如何在R中添加时间戳? [英] How to add timestamp in R?

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

问题描述

我有一个数据,其中包含事件的开始时间和结束时间之间的差异.现在我想添加差异.问题是时差的格式是

I have a data which have the difference between the start and end time of an event. Now I want to add the difference. the problem is the difference time is in format

difference_time
_______________
00:10:00
00:30:12
01:09:09
00:09:03
01:09:30
01:09:03
00:09:08
01:00:09
09:00:01

但是如果我执行 sum(df$difference_time) 它会抛出无效类型争论的错误.

But if I do sum(df$difference_time) it throws the error that invalid type of arguement.

我希望结果类似于以下格式:

I want the result to be something like below format:

51975 秒.任何帮助表示赞赏

51975 seconds. Any help is appreciated

更新:

我尝试了 period_to_seconds(hms(df$difference_time)) 并且它工作正常

I tried period_to_seconds(hms(df$difference_time)) and it works fine

推荐答案

period_to_seconds(hms(df$difference_time)) 

成功了.

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

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