I've spent a few hours reading various packages documentation, but am still stumped (coming back to using R after a few years away).
I have time data of class character in my data frame e.g. 03:30
How can I convert this to minutes ? i.e. 03:30 goes to 210
Any ideas?
Many thanks indeed.
One option would be
library(lubridate)
as.numeric(hm(str1)) /60
#[1] 210
Or specifically convert to seconds with period_to_seconds
and divide by 60
period_to_seconds(hm(str1))/60
#[1] 210
str1 <- "03:30"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With