Re: [R] converting to time series object : ts - package:stats

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Mon 26 Jun 2006 - 23:31:37 EST

On Mon, 26 Jun 2006, Sachin J wrote:

> Hi,
>
> I am trying to convert a dataset (dataframe) into time series object
> using ts function in stats package. My dataset is as follows:
>
> >df
> [1] 11.08 7.08 7.08 6.08 6.08 6.08 23.08 32.08 8.08 11.08 6.08 13.08 13.83 16.83 19.83 8.83 20.83 17.83
> [19] 9.83 20.83 10.83 12.83 15.83 11.83

Please provide a reproducible example. You just showed us the print output for an object, claiming that it is an object of class "data.frame" which is rather unlikely given the print output.

> I converted this into time series object as follows
>
> >tsdata <- ts((df),frequency = 12, start = c(1999, 1))

which produces the right result for me if `df' is a vector or a data.frame:

df <- c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 8.08, 11.08,

        6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 9.83, 20.83,
        10.83, 12.83, 15.83, 11.83)

ts(df, frequency = 12, start = c(1999, 1)) ts(as.data.frame(df), frequency = 12, start = c(1999, 1))

> The resulting time series is as follows:
>
> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
> 1999 2 15 15 14 14 14 12 13 16 2 14 5
> 2000 6 8 10 17 11 9 18 11 1 4 7 3
>
> I am unable to understand why the values of df and tsdata does not match.

So are we because you didn't really tell us enough about df...

Best,
Z

> I looked at ts function and I couldn't find any data transformation. Am
> I missing something here? Any pointers would be of great help.
>
> Thanks in advance.
>
> Sachin
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jun 26 23:47:38 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 27 Jun 2006 - 00:12:11 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.