[R] Construct time series objects from raw data stored in csv files

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Thu Apr 12 20:52:50 CEST 2007


On Thu, 12 Apr 2007, tom soyer 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?

With the "zoo" package you can do
  library("zoo")
  z <- read.zoo("yourdata.csv", sep = ",")
  plot(z)

See
  vignette("zoo", package = "zoo")
for more information and also some more details about other time series
classes.
Z

> Thanks,
>
> Tom
>
> ----------------------------------- 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
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list