2

All the answers that I've found for this question have to do with ggplot2 and other plotting applications. I'd like to know how I can store time information as a date-time object without extraneous date information.

E.g.:

strptime("09:13", format = "%H:%M")

becomes

"2014-03-26 09:13:00"

For my application the default date stamp is irrelevant, and since I'm doing calculations over a large array it actually just adds a lot of unnecessary data. How do I get a date-time object that looks like this instead?:

"09:13:00"
aaron
  • 6,339
  • 12
  • 54
  • 80
  • Could you convert it to character and use `strsplit`? or do you need to keep it class `Date`? – Rich Scriven Mar 26 '14 at 19:14
  • Good thought, Richard. Since I want to preserve the time-ordering I need to keep this field in Date class. Thanks for the tip, though. – aaron Mar 26 '14 at 19:17
  • No worries. I know this is annoying. I was trying something similar last night. – Rich Scriven Mar 26 '14 at 19:19
  • it seems like it should be fairly straight-forward, right? i've combed through all the POSIX, strptime, and as.Date documentation along with all the posts on this site and can't find a straight-forward answer. – aaron Mar 26 '14 at 19:23
  • 2
    See http://stackoverflow.com/questions/22659947/r-how-to-handle-times-without-dates/22665577#22665577 – G. Grothendieck Mar 26 '14 at 19:25
  • that's it, thanks. unfortunately then ggplot2 doesn't know how to automatically set an appropriate default scale for times, which would have been nice. guess you can't have your cake and eat it, too – aaron Mar 26 '14 at 20:05
  • 1
    Perhaps `scale_x_chron` is relevant for you? – Henrik Mar 26 '14 at 21:55

0 Answers0