How to work with time in POSIXlt format using gvisMotionChart?

The googleVis software package R software is surprisingly good. However, I am puzzled by one gvisMotionChart problem about timevar, because the time in my dataset is in POSIXlt format, for example:

 "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" 

Since the unit of time is equal to the hour, if I convert the POSIXlt format format to the date format (using as.date), the clock information will be deleted and make the data meaningless.

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

+4
source share
1 answer

Going with what is in googleVis help, there is no way to do this. You can convert the POSIXlt (or POSIXct ) date and time POSIXlt to numeric, and this will work, although obviously the axis notation will not be as friendly as it could be.

I would try as.numeric() in your date data for the gvisMotionChart function, and then explore the extension options, if possible. I'm not sure that the restriction applies to the implementation of the googleVis package or the Google visualization API, but it would be useful to find out. Either the R package or the API may be expanded in the future.

+3
source

All Articles