将给定字符串转换为分钟(Convert the Given String to Minutes)

系统教程 行业动态 更新时间:2024-06-14 16:58:00
将给定字符串转换为分钟(Convert the Given String to Minutes)

我有一个以String格式表示时间的列。 格式为PT5H1M15S which is equivalent to 5 Hour 1 Minute and 15 Second(Pacific Time) 。 我是R的新手,需要将其转换为Minutes。 任何帮助在这里表示赞赏。 谢谢。

我的预期答案是301.25分钟

I have a column with the time in String format. The format is PT5H1M15S which is equivalent to 5 Hour 1 Minute and 15 Second(Pacific Time). I am new to R and need to convert this to Minutes. Any help here is appreciated. Thanks.

My expected answer is 301.25 Minutes

最满意答案

我们可以使用lubridate

library(lubridate) period_to_seconds(hms(str1))/60 #[1] 301.25

要么

as.numeric(hms(str1))/60 #[1] 301.25

数据

str1 <- "PT5H1M15S"

We can use lubridate

library(lubridate) period_to_seconds(hms(str1))/60 #[1] 301.25

Or

as.numeric(hms(str1))/60 #[1] 301.25

data

str1 <- "PT5H1M15S"

更多推荐

本文发布于:2023-04-14 05:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/0f9094104611ce73321336ef5043f835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   字符串   Convert   String   Minutes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!