[R] How to import time-series data

Gabor Grothendieck ggrothendieck at gmail.com
Sun Feb 12 17:22:57 CET 2012

On Sun, Feb 12, 2012 at 10:52 AM, RichardSmith
<richardsmith404 at gmail.com> wrote:
> Sorry for this very basic question. I have time-series data, laid out as a
> table (in csv) like this:
> That is, the first column is the sample ID, and subsequent columns are the
> data at time interval in days since the start. In Excel, this is a very
> normal way to lay out time-series data, but I can't find any way to work
> with it in R. I want to import the data to R so I can, for example, plot the
> data for each sample. If I import as a matrix or table, R renames the day
> numbers to e.g. X20 instead of 20. What is the correct way to do this?
> Many thanks,
> Richard

Something seems to have gone wrong in the posting since we can't see
the sample data that seems to be intended to be part of the post.  At
any rate read.zoo in the zoo package can read series.  You may need to
use the split= argument if your file defines multiple series tagged by
an id column.  See ?read.zoo and the Reading Data in Zoo vignette
which is online here
and is an entire document devoted to reading time series.  Alternately
its available in R through the vignette("zoo-read") command.

Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

More information about the R-help mailing list