4

The googleVis package of R software is surprisingly good. However, I am puzzled by one problem of gvisMotionChart about the timevar, because the time in my data set is POSIXlt format, such as:

"2009-07-02 19:00:00" "2009-07-02 20:00:00" "2009-07-02 21:00:00" "2009-07-02 22:00:00" "2009-07-02 23:00:00"

Because the time unit is hour, if I transform the POSIXlt format to date format(using as.date), the hours information will be deleted and make the data nonsense.

So my question is: how to deal with the POSIXlt format time using gvisMotionChart?

Andrie
  • 176,377
  • 47
  • 447
  • 496
Frank Wang
  • 1,462
  • 3
  • 17
  • 39
  • 1
    In general, it will be easier to help you if you provide sample data and code. See http://stackoverflow.com/q/5963269/602276 for tips on how to do this. – Andrie Sep 19 '11 at 07:00

1 Answers1

3

Going by what is in the googleVis help there is no way to do this. You could transform your POSIXlt (or POSIXct) date-time data to numeric and it will work, though obviously the axis notation won't be as friendly as it could be.

I would try as.numeric() on your date-time data for the gvisMotionChart function, and then explore options to extend this if possible. I'm not sure if the limitation is with the googleVis package implementation or the Google Visualisation API, but that would be worth finding out. Either the R package and/or the API may be extended in the future.

mdsumner
  • 29,099
  • 6
  • 83
  • 91
  • 1
    I consult with Markus Gesmann, and he gave similar reply. "Unfortunately the Motion Chart does not accept POSIXt format for the time variable. Please see the documentation and also http://code.google.com/apis/chart/interactive/docs/gallery/motionchart.html#Data_Format You will have to either convert the POSIXt column into a number, or use alternative visualisations which support this format, e.g. gvisAnnotatedTimeLine." Thank you. – Frank Wang Sep 19 '11 at 08:37
  • 1
    Ok, and it looks like the gvis API is limited to days so you are out of luck. That seems very limiting! – mdsumner Sep 19 '11 at 09:03
  • Is there any indication if the extension to include POSIXct/POSIXlt is going to be included anytime in the near future? – h.l.m Aug 04 '12 at 11:50