Plot a time series
iidda_series.RdPrepare a data set for plotting (trimming, handling missing/zero values, converting the time variable), build a line chart, and apply title, subtitle, and theme.
Usage
iidda_series(
  data,
  series_variable = NULL,
  time_variable = NULL,
  trim_series = TrimSeries(zero_lead = FALSE, zero_trail = FALSE),
  handle_missing_values = HandleMissingValues(na_remove = FALSE, na_replace = NULL),
  handle_zero_values = HandleZeroValues(zero_remove = FALSE, zero_replace = NULL),
  time_variable_converter = TimeVariableConverter(),
  title = TitleGuesser(),
  subtitle = TimeRangeDescriber(),
  theme = iidda_theme
)
iidda_attach_series(
  data,
  initial_ggplot_object = ggplot(),
  series_variable = NULL,
  time_variable = NULL
)
iidda_prep_ma(
  data,
  series_variable = NULL,
  time_variable = NULL,
  trim_series = TrimSeries(zero_lead = FALSE, zero_trail = FALSE),
  handle_missing_values = HandleMissingValues(na_remove = FALSE, na_replace = NULL),
  handle_zero_values = HandleZeroValues(zero_remove = FALSE, zero_replace = NULL),
  compute_moving_average = ComputeMovingAverage(ma_window_length = 52),
  time_variable_converter = TimeVariableConverter()
)
iidda_prep_series(
  data,
  series_variable = NULL,
  time_variable = NULL,
  trim_series = TrimSeries(zero_lead = FALSE, zero_trail = FALSE),
  handle_missing_values = HandleMissingValues(na_remove = FALSE, na_replace = NULL),
  handle_zero_values = HandleZeroValues(zero_remove = FALSE, zero_replace = NULL),
  time_variable_converter = TimeVariableConverter()
)Arguments
- data
 A data frame containing the time-series data (typically output from
iidda_prep_series()).- series_variable
 Name of the series column in
data(e.g.,"deaths").- time_variable
 Name of the time column in
data(e.g.,"period_end_date").- trim_series
 A
TrimSeries(...)specification controlling removal of leading/trailing zeros. Default:TrimSeries(zero_lead = FALSE, zero_trail = FALSE).- handle_missing_values
 A
HandleMissingValues(...)specification controlling NA handling. Default:HandleMissingValues(na_remove = FALSE, na_replace = NULL).- handle_zero_values
 A
HandleZeroValues(...)specification controlling zero handling. Default:HandleZeroValues(zero_remove = FALSE, zero_replace = NULL).- time_variable_converter
 A
TimeVariableConverter(...)specifying how to parse/convert the time variable. Default:TimeVariableConverter().- title
 A plot title, or a function that takes
dataand returns a title string.- subtitle
 A plot subtitle, or a function that takes
dataand returns a subtitle string.- theme
 A function that returns a
ggplot2::themeobject.- compute_moving_average
 function to compute the moving average of
series_variable
Value
A ggplot2 plot object containing the time-series line chart with title, subtitle, and theme applied.
Functions
iidda_attach_series(): Attach a time-series plot to a data frame containing the plotted data.iidda_prep_ma(): Prepare a dataset so that it can be used to produce a time-series plot of a moving average.iidda_prep_series(): Prepare a dataset so that it can be used to produce a time-series plot.