Thanks Gabor!

I think your example works, but check this out:

> as.ts(z)
      Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3
1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9
> is.ts(z)
[1] FALSE
>

How come R does not recognize z as a ts object? It is a ts object, isn't it?

On 4/12/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
>
> On 4/12/07, tom soyer <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have time series data stored in csv files (see below for an example of
> the
> > data). I understand that in order to analyze my data in R, I need to
> first
> > transform it into a ts object. Howeve, I could not find an example on
> how
> > exactly to do that. Is ts the only function I need? What are the steps
> that
> > I need to go through to build a time series object from raw data like
> this?
> >
>
> Try pasting this into an R session:
>
>
>
> Lines.raw <- "DATE,VALUE
> 1921-01-01,19.000
> 1921-02-01,18.400
> 1921-03-01,18.300
> 1921-04-01,18.100
> 1921-05-01,17.700
> 1921-06-01,17.600
> 1921-07-01,17.700
> 1921-08-01,17.700
> 1921-09-01,17.500
> 1921-10-01,17.500
> 1921-11-01,17.400
> 1921-12-01,17.300
> 1922-01-01,16.900
> 1922-02-01,16.900
> 1922-03-01,16.700
> 1922-04-01,16.700
> 1922-05-01,16.700
> 1922-06-01,16.700
> 1922-07-01,16.800
> 1922-08-01,16.600
> 1922-09-01,16.600
> 1922-10-01,16.700
> 1922-11-01,16.800
> 1922-12-01,16.900
> "
> library(zoo)
> # replace next line with something like this:
> #  z <- read.zoo("myfile.dat", header = TRUE, sep = ",")
> z <- read.zoo(textConnection(Lines.raw), header = TRUE, sep = ",")
> time(z) <- as.yearmon(time(z))
> as.ts(z)
>



-- 
Tom

        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] 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.

Reply via email to