trend_line {epitweetr}R Documentation

Plot the trendline report of epitweetr dashboard

Description

Generates a trendline chart of number of tweets by region, for one topic, including alerts using the reweighted version of the EARS algorithm

Usage

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

Arguments

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_retweets

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

location_type

Character(1) vector indicating the location type. Possible values 'tweet', 'user' or 'both', default: 'tweet'

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 tweets 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 for the previous hour of the last collected tweet.

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

Value

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

See Also

create_map create_topwords generate_alerts aggregate_tweets geotag_tweets detect_loop search_loop

Examples

if(FALSE){
   message('Please choose the epitweetr 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())
   ) 
}

[Package epitweetr version 0.1.28 Index]