Learn R Programming

globaltrends (version 0.0.14)

plot_ts: Plot time series of globaltrends data

Description

The function creates line plots for time series globaltrends data. It uses the output of export_... or get_abnorm_hist to prepare line plots for up to nine keywords.

Usage

plot_ts(data, ...)

# S3 method for exp_score plot_ts(data, type = c("obs", "sad", "trd"), smooth = TRUE, ...)

# S3 method for abnorm_score plot_ts(data, ci = 0.95, ...)

# S3 method for exp_voi plot_ts(data, type = c("obs", "sad", "trd"), smooth = TRUE, ...)

# S3 method for abnorm_voi plot_ts(data, ci = 0.95, ...)

# S3 method for exp_doi plot_ts( data, type = c("obs", "sad", "trd"), measure = c("gini", "hhi", "entropy"), locations = "countries", smooth = TRUE, ... )

# S3 method for abnorm_doi plot_ts( data, type = c("obs", "sad", "trd"), locations = "countries", ci = 0.95, ... )

Value

Line plot of time series as ggplot2 object. For plots for output from get_abnorm_hist the provided confidence interval is indicated by red dots.

Arguments

data

Data exported from export_... or compute_abnorm functions.

...

Further arguments passed to or from other methods.

type

Object of type character indicating the type of time series-column from data_score, takes either obs, sad, or trd. Defaults to "obs".

smooth

Object of type logical indicating whether the geom_smooth function of ggplot2 should be used. Defaults to TRUE.

ci

Confidence interval within which changes are assumed to be normal. Object of type double, 0 < ci < 1. Defaults to 0.95.

measure

Object of type character indicating the DOI measure, takes either gini, hhi, or entropy. Defaults to "gini".

locations

Object of type character indicating for which set of locations should be filtered. Defaults to "countries".

Details

For output of export_score, only data for a single location is shown. When date for more than one location is provided, the function selects only the first location. For output of get_abnorm_hist, users can specify confidence intervals to highlight abnormal changes in the data.

Examples

Run this code
if (FALSE) {
data <- export_score(keyword = "amazon")
plot_ts(data, type = "obs")

data <- export_voi(keyword = "amazon")
data <- get_abnorm_hist(data, train_win = 12, train_break = 0, type = "obs")
plot_ts(data)

data <- export_doi(keyword = "amazon")
data <- get_abnorm_hist(data, train_win = 12, train_break = 0, measure = "gini")
plot_ts(data, ci = 0.9)
}

Run the code above in your browser using DataLab