Skip to contents

Event Helpers: fg_cut_to_events

Usage

fg_cut_to_events(
  indta,
  ncutsperside = 4,
  center = 0,
  extend = TRUE,
  invert = FALSE
)

Arguments

indta

Time series data.table with a date as the first column and a value series as the second column.

ncutsperside

: Integer with number of colors to use on each side of 'center'

center

: String or Double as follows:

  • Double (default 0) Normalize data by subtracting center

  • "median" Normalize data by subtracting median of all observations.

  • "zscore" Normalize data by using standard scale() function

extend

Logical (Default: TRUE) to extend data to today (Sys.Date()) data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAbElEQVR4Xs2RQQrAMAgEfZgf7W9LAguybljJpR3wEse5JOL3ZObDb4x1loDhHbBOFU6i2Ddnw2KNiXcdAXygJlwE8OFVBHDgKrLgSInN4WMe9iXiqIVsTMjH7z/GhNTEibOxQswcYIWYOR/zAjBJfiXh3jZ6AAAAAElFTkSuQmCC

invert

Use opposite color schemes for data, i.e. "red" for good outcomes

Value

data.table suitable for passing into fgts_dygraph() via the event_ds parameter

Details

Always uses first date column and first numeric columns in data. If indta has multiple series, filter them before calling the function.

Examples

smalldta <- narrowbydtstr(eqtypx[,.(date,IBM,QQQ)],"-2y::")
events <- fg_cut_to_events(consumer_sent,center="zscore")
fgts_dygraph(smalldta,title="With Sentiment ranges",event_ds=events)