Вам нужно сначала исправить введенную строку. Я предполагаю, что это hours:minutes:seconds:milliseconds:microseconds
.
timedata <- "08:39:41:759:520"
#replace last two :
timedata <- gsub(":(?=\\d*$)", ".",
gsub(":(?=\\d*$)", "",
timedata,
perl = TRUE),
perl = TRUE)
#coerce to POSIXct and subtract current date
timedata <- as.numeric(as.POSIXct(timedata, '%H:%M:%OS', tz='UTC')) -
as.numeric(as.POSIXct(Sys.Date()))
#this is a floating point number, print digits of interest (following digits can't be zero)
sprintf("%.6f",timedata)
#[1] "31181.759520"