ts_calendar_heatmap_plt: Time Series Calendar Heatmap

Description Usage Arguments Details Value Author(s) Examples

View source: R/time_series_control_charts.R

Description

Takes in data that has been aggregated to the day level and makes a calendar heatmap.

Usage

1
2
3
4
5
6
7
8
9
ts_calendar_heatmap_plt(
  .data,
  .date_col,
  .value_col,
  .low = "red",
  .high = "green",
  .plt_title = "",
  .interactive = TRUE
)

Arguments

.data

The time-series data with a date column and value column.

.date_col

The column that has the datetime values

.value_col

The column that has the values

.low

The color for the low value, must be quoted like "red". The default is "red"

.high

The color for the high value, must be quoted like "green". The default is "green"

.plt_title

The title of the plot

.interactive

Default is TRUE to get an interactive plot using plotly::ggplotly(). It can be set to FALSE to get a ggplot plot.

Details

The data provided must have been aggregated to the day level, if not funky output could result and it is possible nothing will be output but errors. There must be a date column and a value column, those are the only items required for this function to work.

This function is intentionally inflexible, it complains more and does less in order to force the user to supply a clean data-set.

Value

A ggplot2 plot or if interactive a plotly plot

Author(s)

Steven P. Sanderson II, MPH

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(LICHospitalR)
library(tidyverse)
library(timetk)
library(lubridate)
library(zoo)
library(scales)

data_tbl <- ts_ed_arrivals_query() %>%
  ts_ed_arrivals_tbl(.date_col = date_col, .by_time = "day") %>%
  filter_by_time(.date_var = date_col, .start_date = "2021") %>%
  set_names("date_col","value")

ts_calendar_heatmap_plt(
  .data        = data_tbl
  , .date_col  = date_col
  , .value_col = value
)

ts_calendar_heatmap_plt(
  .data          = data_tbl
  , .date_col    = date_col
  , .value_col   = value
  , .interactive = FALSE
)

spsanderson/LICHospitalR documentation built on Jan. 6, 2022, 12:32 a.m.