ggts: Plot time series using ggts

Description Usage Arguments Value Examples

Description

Plot time series using ggts

Usage

1
2
ggts(.data, ..., linetype = TRUE, color = FALSE, standardize = FALSE,
  index = FALSE)

Arguments

.data

the data to be plotted. Either a dataframe with a time column (e.g. a "Date", "POSIXlt", or "POSIXct" object), a ts or mts object, zoo object, or xts object.

...

arguments to be passed to dplyr select. If a dplyr helper frunction is used, e.g. matches, dplyr must be loaded or the function must be pasted via dplyr::matches("x")

linetype

(logical) if TRUE, linetypes will be used

color

(logical) if TRUE, color will be used

standardize

(logical) If set to TRUE, all time series will be standardized to have zero mean and unit variance before plotting. Default is FALSE

index

(logical) If set to TRUE, all time series will be tranformed into an index using x / x[1] - 1

Value

a ggplot of the time series

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
data(AirPassengers) ##A ts object
ggts(AirPassengers)

## Interest rates from the Stock and Watson dataset
library(AER)
data(USMacroSW)  ##a mts object
ggts(USMacroSW, ffrate, tbill, tbond)
##Interest rates with colors from the Stock and Watson dataset
ggts(USMacroSW, ffrate, tbill, tbond, color = TRUE)
##Index values for CPI and Japanese GDP from SW datasets
ggts(USMacroSW, cpi, gdpjp, index = TRUE)
##Standardized unemployment rate and Pound/Dollar exchange rate
ggts(USMacroSW, cpi, gdpjp, standardize = TRUE)

library(xts)
data(AAPL.data) ##xts object
##Plot everything but volume using dplyr matches helper function.
##Note that all dplyr select helper functions can be used, but
##either dplyr must be attached or the package explicitly referenced
##(below example)
ggts(AAPL.data, -dplyr::matches("Volume"))

##If we have a randomly placed time column
USMacroSW2 <- as_ts_df(USMacroSW)[, c("ffrate", "tbill", "time", "tbond")]
names(USMacroSW2)[3] <- "date"
ggts(USMacroSW2)

##If more than 1 time column, ggts() will output a message
##saying that only the first time column will be used
USMacroSW3 <- USMacroSW2
USMacroSW3$date2 <- USMacroSW2$date
ggts(USMacroSW3)

##Using a normal dataframe
data(economics)
ggts(economics, psavert, uempmed)

ChandlerLutz/ggts documentation built on May 6, 2019, 9:56 a.m.