-3

I would like to convert a time to total milliseconds in R.

Example

13:00 -> 46800000

Roni Hoffman
  • 302
  • 1
  • 5
  • 17

1 Answers1

4

For the fun of it:

f <- function(v) sapply(strsplit(v, ":", T), function(x) sum(as.numeric(x) * c(60*60, 60, 1)[seq(x)]*1000))
f(c("13:00", "13:00:00", "14:00:00.001"))       
# [1] 46800000 46800000 50400001
lukeA
  • 53,097
  • 5
  • 97
  • 100