How to add timestamp in R?

天大地大妈咪最大 提交于 2021-02-11 11:53:05

问题


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

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 seconds. Any help is appreciated

UPDATE:

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


回答1:


period_to_seconds(hms(df$difference_time)) 

did the trick.



来源:https://stackoverflow.com/questions/44242291/how-to-add-timestamp-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!