I have a dataset where the time column values are written as a character phrase.
Example: "1 hour and 20 minutes"
I want to make the time machine readable for different calculations. How do I change "1 hour and 20 minutes" to "80"?
Thank you!
I have a dataset where the time column values are written as a character phrase.
Example: "1 hour and 20 minutes"
I want to make the time machine readable for different calculations. How do I change "1 hour and 20 minutes" to "80"?
Thank you!
You can use lubridate package to do that.
Using hm function and then as.numeric as shown below.
library(lubridate)
f1<-"1 hour and 20 minutes"
as.numeric(hm(f1), "minutes")
#> [1] 80
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.