Learn R Programming

DTSg (version 0.2.0)

alter.DTSg: Alter Time Series

Description

Shortens, lengthens and/or changes the periodicity of a DTSg object.

Usage

# S3 method for DTSg
alter(x, from = first(self$values(TRUE)[[1L]]),
  to = last(self$values(TRUE)[[1L]]), by = self$periodicity,
  rollback = TRUE, clone = getOption("DTSgClone"), ...)

Arguments

x

A DTSg object (S3 method only).

from

A POSIXct date with the same time zone as the time series or a character string coercible to one. Specifies the new start of the time series.

to

A POSIXct date with the same time zone as the time series or a character string coercible to one. Specifies the new end of the time series.

by

Specifies the new periodicity in one of the ways the by argument of seq.POSIXt can be specified. Must be specified for time series with unrecognised periodicity. Time steps out of sync with the new periodicity are dropped.

rollback

A logical specifying if a call to rollback is made when appropriate.

clone

A logical specifying if the object is modified in place or if a clone (copy) is made beforehand.

Not used (S3 method only).

Value

Returns a DTSg object.

See Also

DTSg, values, POSIXct, seq.POSIXt, rollback

Examples

Run this code
# NOT RUN {
# new DTSg object
x <- DTSg$new(values = flow)

# extract the first two years
## R6 method
x$alter(from = "2007-01-01", to = "2008-12-31")

## S3 method
alter(x = x, from = "2007-01-01", to = "2008-12-31")

# }

Run the code above in your browser using DataLab