timeseries: Create a 'timeSeries' Object

Description Usage Arguments See Also Examples


Creates an object of class timeSeries.


timeSeries(data, positions., units., from = timeCalendar(d = 1,
    m = 1, y = 1960), by = "days", k.by = 1, align.by = FALSE,
    week.align = NULL)



(ANY) the variable data. Can be any data object for which is.rectangular is TRUE, such as a data.frame, matrix, or atomic vector.


(positions) the x values for the variables. Must be of type positionsCalendar. If not given, then the positions are computed using the timeSeq function with the from, by, k.by, align and week.align arguments.


(character) the units for the data.


the starting value of the sequence. A timeDate object (or number or character string representing one).


the spacing between successive values in the sequence. Can be a timeSpan, timeRelative, or numeric value, in which case k.by is ignored.

Alternatively, it can be one of the following character strings:

  • "milliseconds"

  • "seconds"

  • "minutes"

  • "hours"

  • "days"

  • "weekdays"

  • "bizdays"

  • "weeks"

  • "months"

  • "quarters"

  • "years"

giving the time units of intervals between values in the sequence.


a non-zero integer giving the width of the interval between consecutive values in the sequence in terms of the units given in by. Ignored if by is not a character string.


a logical value. If TRUE, adjusts the sequence so that each element is on a whole number of the by * k.by units. For example, if the units are 2 months, the sequence is only on the first of January, March, and so on. Ignored if by is not a character string.


if by is "weeks", you can supply a character string (or a number, 0 to 6 with 0 being Sunday) to specify a weekday to use. (The character string must be sufficient to make a unique case-insensitive match to the strings in timeDateOptions("time.day.name").)

  • If align.by is FALSE, the sequence is adjusted so that all its elements fall on the given weekday.

  • If align.by is TRUE, the sequence is adjusted to start at midnight.

In either case, the extend argument is used to decide which direction to adjust the day. This argument is ignored if by is not a character string, or if it is not "weeks".

See Also

timeSeries class, timeSequence.


timeSeries( pos=timeCalendar( d=1:10 ), data = 1:10)
timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays")

splusTimeSeries documentation built on April 30, 2021, 5:09 p.m.