[R] convert time series to data.frame

Edna Bell edna.bell01 at gmail.com
Mon Oct 1 06:45:43 CEST 2007


Hi again
Here is the sample:
> yuk
       Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
2005 41.26 40.02 38.24 35.37 39.35 38.90 43.51 40.32 38.14 41.04 41.78 40.48
2006 40.55 42.15 42.30 39.93 38.12 35.79 34.71 34.29 36.27 37.33 37.97 40.16
2007 40.74 39.59 36.74 37.87 38.87 39.35 37.17 38.31 32.44
> as.data.frame(yuk)
   zoo(coredata(x), tt)
1                 41.26
2                 40.02
3                 38.24
4                 35.37
5                 39.35
6                 38.90
7                 43.51
8                 40.32
9                 38.14
10                41.04
11                41.78
12                40.48
13                40.55
14                42.15
15                42.30
16                39.93
17                38.12
18                35.79
19                34.71
20                34.29
21                36.27
22                37.33
23                37.97
24                40.16
25                40.74
26                39.59
27                36.74
28                37.87
29                38.87
30                39.35
31                37.17
32                38.31
33                32.44
>

Ideally, the time element would be there for plotting purposes.

thanks


On 9/30/07, Jeffrey Robert Spies <jspies at nd.edu> wrote:
> Hi Edna,
>
> Can you send a small subset of the data as an example and the
> function call you used to read the data in originally?  It might be
> helpful in understanding why you're losing the "time element".
>
> Jeff.
>
> On Oct 1, 2007, at 12:27 AM, Edna Bell wrote:
>
> > Dear R gurus
> >
> > I would like to take a monthly time series and convert it to a data
> > frame without losing the tsp items, pleae
> >
> > I've tried as.data.frame and data.frame but I get the series without
> > the time element.
> >
> > Any suggestions, please?
> >
> > tia
> >
> > Edna Bell
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list