trend_line: Plot the trendline report of episomer dashboard

View source: R/dataviz.R

trend_lineR Documentation

Plot the trendline report of episomer dashboard

Description

Generates a trendline chart of number of posts by region for a single topic, including alerts detected using the reweighted version of the EARS algorithm

Usage

trend_line(
  sms,
  topic,
  countries = c(1),
  date_type = "created_date",
  date_min = "1900-01-01",
  date_max = "2100-01-01",
  with_quotes = FALSE,
  alpha = 0.025,
  alpha_outlier = 0.05,
  k_decay = 4,
  no_historic = 7,
  bonferroni_correction = FALSE,
  same_weekday_baseline = FALSE
)

Arguments

sms

Social media

topic

Character(1) containing the topic to use for the report

countries

Character vector containing the name of the countries and regions to plot or their respective indexes on the Shiny app select, default: c(1)

date_type

Character vector specifying the time granularity of the report either 'created_weeknum' or 'created_date', default: 'created_date'

date_min

Date indicating start of the reporting period, default: "1900-01-01"

date_max

Date indicating end of the reporting period, default: "2100-01-01"

with_quotes

Logical value indicating whether to include reposts in the time series, default: FALSE

alpha

Numeric(1) value indicating the alert detection confidence, default: 0.025

alpha_outlier

Numeric(1) value indicating the outliers detection confidence for downweighting, default: 0.05

k_decay

Strength of outliers downweighting, default: 4

no_historic

Number of observations to build the baseline for signal detection, default: 7

bonferroni_correction

Logical value indicating whether to apply the Bonferroni correction for signal detection, default: FALSE

same_weekday_baseline

Logical value indicating whether to use same day of weeks for building the baseline or consecutive days, default: FALSE

Details

Produces a multi-region line chart for a particular topic of number of posts collected based on the provided parameters. Alerts will be calculated using a modified version of the EARS algorithm that applies a Farrington inspired downweighting of previous outliers.

Days in this function are considered as contiguous blocks of 24 hours, starting from the previous hour preceding the last collected post.

This function requires that search_loop and detect_loop have already run successfully in order to show results.

Value

A named list containing two elements: 'chart' with the ggplot2 figure and 'data' containing the data frame that was used to build the chart.

See Also

create_map create_topwords generate_alerts detect_loop search_loop

Examples

## Not run: 
   message('Please choose the episomer data directory')
   setup_config(file.choose())
   #Getting trendline for dengue for South America for the last 30 days
   trend_line(
     topic = "dengue",
     countries = "South America",
     date_min = as.Date(Sys.time())-30,
     date_max=as.Date(Sys.time())
   )

## End(Not run)

episomer documentation built on Nov. 26, 2026, 5:07 p.m.