[R] initializing timeseries with ts()

Prof Brian Ripley
Fri, 16 Aug 2013 06:27:09 -0000

On 15/08/2013 21:11, Daren Zou wrote:
> Hi, i was messing around with R and noticed that there is an object for
timeseries which can be initialized with the ts() function. however it seems
that it can only be initialized with a vector of data points and its assumed
that these data points occur at regular time periods, user to specify frequency
> and there is no way to initialize a timeseries object with two vectors, one
of datetimes and another of actual data points
> anyone know if my understanding is accurate?

Read the help page, ?ts .

      The function ?ts? is used to create time-series objects.  These
      are vector or matrices with class of ?"ts"? (and additional
      attributes) which represent data which has been sampled at
      equispaced points in time.

That is the definition used in almost all work on time series in
statistics.  And the claim that the vector or matrix need be numeric is
false.

There are several packages which handle un-equally spaced series:
http://cran.r-project.org/web/views/TimeSeries.html .


> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

PLEASE do.


--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595