Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.DTSg

Plot Time Series


Description

Displays an interactive plot of a DTSg object. This method requires dygraphs and RColorBrewer to be installed. Its main purpose is not to make pretty plots, but rather to offer a possibility to interactively explore time series. The title of the plot and the label of its primary axis are automatically generated out of the object's metadata (fields). See DTSg for further information.

Usage

## S3 method for class 'DTSg'
plot(
  x,
  from = first(self$values(reference = TRUE)[[".dateTime"]]),
  to = last(self$values(reference = TRUE)[[".dateTime"]]),
  cols = self$cols(class = "numeric"),
  secAxisCols = NULL,
  secAxisLabel = "",
  ...
)

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. The time series is plotted from this date on.

to

A POSIXct date with the same time zone as the time series or a character string coercible to one. The time series is plotted up to this date.

cols

A character vector specifying the columns whose values shall be plotted.

secAxisCols

An optional character vector specifying the columns whose values shall be plotted on a secondary axis. Must be a subset of cols.

secAxisLabel

A character string specifying the label of the optional secondary axis.

...

Not used (S3 method only).

Value

Returns a DTSg object.

See Also

Examples

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

# plot time series
if (requireNamespace("dygraphs", quietly = TRUE) &&
    requireNamespace("RColorBrewer", quietly = TRUE)) {
  ## R6 method
  x$plot()

  ## S3 method
  plot(x = x)
}

DTSg

A Class for Working with Time Series Based on 'data.table' and 'R6' with Largely Optional Reference Semantics

v0.7.0
MIT + file LICENSE
Authors
Gerold Hepp [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.