How can I change this to numeric values, the number refers to the record of the 1.5km running, containing min:sec:one-tenth of seconds
"4:04.86" -> 4:04.86
as.numeric function is not working in this case, I think, its because of ':'
How can I change this to numeric values, the number refers to the record of the 1.5km running, containing min:sec:one-tenth of seconds
"4:04.86" -> 4:04.86
as.numeric function is not working in this case, I think, its because of ':'
Here's a way with lubridate that gives the result in seconds.
library(lubridate)
x <- "4:04.86"
period_to_seconds(ms(x))
# [1] 244.9
Base R can handle this a-okay too, using ?as.difftime
:
as.difftime("4:04.86", format="%M:%OS")
#Time difference of 4.081 mins
as.difftime("4:04.86", format="%M:%OS", units="secs")
#Time difference of 244.86 secs