alter.DTSg: Alter time series

alter.DTSgR Documentation

Alter time series

Description

Shortens, lengthens, filters for a consecutive range, changes the periodicity and/or the status of missing values of a DTSg object.

Usage

## S3 method for class 'DTSg'
alter(
  x,
  from = first(self$values(reference = TRUE)[[".dateTime"]]),
  to = last(self$values(reference = TRUE)[[".dateTime"]]),
  by = self$periodicity,
  rollback = TRUE,
  clone = getOption("DTSgClone"),
  na.status = self$na.status,
  ...
)

Arguments

x

A DTSg object (S3 method only).

from

A POSIXct timestamp in 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 timestamp in 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 shall be made when appropriate.

clone

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

na.status

A character string. Either "explicit", which makes missing timestamps explicit according to the recognised periodicity, or "implicit", which removes timestamps with missing values on all value columns. Please note that DTSg objects work best with explicitly missing values.

...

Not used (S3 method only).

Value

Returns a DTSg object.

See Also

getOption, subset, nas

Examples

# new DTSg object
x <- DTSg$new(values = flow)

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

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

# change periodicity to one month
## R6 method
x$alter(by = "1 month")$print()

## S3 method
print(alter(x = x, by = "1 month"))


gisler/DTSg documentation built on Jan. 11, 2024, 4:59 a.m.