Hello Guys, How are you all? Hope You all Are Fine. I want to convert decimal to MM:SS.XXX in R. How to convert decimal to Datetime Formate in R. So Here I am Explain to you all the possible solutions here.
Without Wasting your time, Lets start This Article to Solve This Error.
What is Issue ?
I have decimal data type and I want to convert decimal to datetime formate. For Example.
myDecimalTime = 82.180
What I want
myDecimalTime = 01:22.11
How to convert decimal to Datetime Formate in R ?
Question: How to convert decimal to Datetime Formate in R?
Answer: To convert decimal to DateTime Just you can use the lubridate package. Here I am giving a full example for better understanding.
Solution 1
To convert decimal to DateTime Just you can use the lubridate package. Here I am giving a full example for better understanding.
package(lubridate)
t <- 82.180
# your output string as character
lubridate::seconds(t) %>%
lubridate::as_datetime() %>%
format("%M:%OS3")
# output as period
lubridate::seconds(t) %>%
lubridate::as.period()
# output as duration
lubridate::seconds(t) %>%
lubridate::as.duration()
# output as time time
lubridate::seconds(t) %>%
lubridate::as.difftime()
Summery
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also Read