0

I have a dataset that contains a column of timestamps. For example "16-Feb-2015 17:41:36.666" and "16-Feb-2015 17:41:36.700" are the elements in first two rows of this column. I am reading from a data-stream where a time-stamp is collected at a rate of 30 instances per second. How do I convert these time-stamp elements from this time-stamp to their corresponding Julian time with millisecond precision? R reads this column as a type factor. I would like this to be a numeric. I have tried using as.character and as.numeric but I sense there is a more specific way to hand time stamps.

Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49
  • Julian time (?) from which origin? –  Nov 04 '15 at 22:54
  • Would `as.Date` work? It would allow you to specify the format, and would get around treating a date like a factor or numeric. – Tad Dallas Nov 04 '15 at 23:39
  • `as.POSIXct(x, format = "%d-%b-%Y %H:%M:%OS")` is the normal way to get millisecond precision (`%OS`) – Rich Scriven Nov 04 '15 at 23:51
  • Sorry forgot to specify origin.... 1/1/1970 is the desired origin. as.Date is something I looked into as well but it doesn't seem like it handles the time portion of the time-stamp... just the date. – Mitch Campion Nov 04 '15 at 23:52
  • Thanks Richard, that is somewhat helpful but now I need to get this POSIX object to be an integer.... The integer being the number of milliseconds since 00:00:00.00 01/01/1970 ..... perhaps I need to do it manually with a string splitting function and multiply accordingly.. I just wondered if there was already a function to do this. – Mitch Campion Nov 04 '15 at 23:56

0 Answers0