[R] getting dates from a ts object

Data Analytics Corp. dataanalytics at earthlink.net
Wed Aug 12 18:51:40 CEST 2009


I have a ts object called data.gas that has three economic variables: 
gasoline consumption (gas), price per gallon (price), and household 
income (income) by month from January 1970 to December 2008.  I want to 
plot this gas and price variables using ggplot2, but ggplot2 will not 
allow an object of class mts or ts; it has to be a data frame.  When I 
use as.data.frame(data.gas), the date information is lost.  How can I 
capture the date information in a vector so I can add it to a data frame 
created using as.data.frame?




Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
(V) 609-936-8999
(F) 609-936-3733
dataanalytics at earthlink.net

More information about the R-help mailing list