How to analyze milliseconds?

How to use strptime or any other functions to parse millisecond timestamps in R?

 time[1] # [1] "2010-01-15 13:55:23.975" strptime(time[1], format="%Y-%m-%d %H:%M:%S.%f") # [1] NA strptime(time[1], format="%Y-%m-%d %H:%M:%S") # [1] "2010-01-15 13:55:23"` 
+63
datetime r time-series strptime
Jan 27 '10 at 20:48
source share
2 answers

Provided by ?strptime help file (with an example changed to your value):

  z <- strptime("2010-01-15 13:55:23.975", "%Y-%m-%d %H:%M:%OS") z # prints without fractional seconds op <- options(digits.secs=3) z options(op) #reset options 
+91
Jan 27 '10 at 20:55
source share

You can also use strptime(time[1], "%OSn") , where 0 <= n <= 6, without having to set digits.secs .

+27
Jan 27
source share



All Articles