autoplot.ts: Automatically create a ggplot for time series objects

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/autoplot.R

Description

autoplot takes an object of type ts or mts and creates a ggplot object suitable for usage with stat_forecast.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## S3 method for class 'ts'
autoplot(
  object,
  series = NULL,
  xlab = "Time",
  ylab = deparse(substitute(object)),
  main = NULL,
  facets = FALSE,
  colour = TRUE,
  ...
)

## S3 method for class 'numeric'
autoplot(
  object,
  series = NULL,
  xlab = "Time",
  ylab = deparse(substitute(object)),
  main = NULL,
  ...
)

## S3 method for class 'ts'
fortify(model, data, ...)

Arguments

object

Object of class “ts” or “mts”.

series

Identifies the time series with a colour, which integrates well with the functionality of geom_forecast.

xlab

a string with the plot's x axis label. By default a NUll value.

ylab

a string with the plot's y axis label. By default a counts" value.

main

a string with the plot's title.

facets

If TRUE, multiple time series will be faceted (and unless specified, colour is set to FALSE). If FALSE, each series will be assigned a colour.

colour

If TRUE, the time series will be assigned a colour aesthetic

...

Other plotting parameters to affect the plot.

model

Object of class “ts” to be converted to “data.frame”.

data

Not used (required for fortify method)

Details

fortify.ts takes a ts object and converts it into a data frame (for usage with ggplot2).

Value

None. Function produces a ggplot2 graph.

Author(s)

Mitchell O'Hara-Wild

See Also

plot.ts, fortify

Examples

1
2
3
4
5
6
library(ggplot2)
autoplot(USAccDeaths)

lungDeaths <- cbind(mdeaths, fdeaths)
autoplot(lungDeaths)
autoplot(lungDeaths, facets=TRUE)

nortsTest documentation built on Aug. 16, 2021, 5:06 p.m.