Learn R Programming

healthyR (version 0.2.0)

ts_plt: Time Series Plot

Description

This is a warpper function to the timetk::plot_time_series() function with a limited functionality parameter set. To see the full reference please visit the timetk package site.

Usage

ts_plt(
  .data,
  .date_col,
  .value_col,
  .color_col = NULL,
  .facet_col = NULL,
  .facet_ncol = NULL,
  .interactive = FALSE
)

Value

A plotly plot or a ggplot2 static plot

Arguments

.data

The data to pass to the function, must be a tibble/data.frame.

.date_col

The column holding the date.

.value_col

The column holding the value.

.color_col

The column holding the variable for color.

.facet_col

The column holding the variable for faceting.

.facet_ncol

How many columns do you want.

.interactive

Return a plotly plot if set to TRUE and a static ggplot2 plot if set to FALSE. The default is FALSE.

Author

Steven P. Sanderson II, MPH

Details

This function takes only a few of the arguments in the function and presets others while choosing the defaults on others. The smoother functionality is turned off.

See Also

Examples

Run this code
suppressPackageStartupMessages(library(dplyr))
library(timetk)
library(healthyR.data)

healthyR.data::healthyR_data %>%
  filter(ip_op_flag == "I") %>%
  select(visit_end_date_time, service_line) %>%
  filter_by_time(
    .date_var = visit_end_date_time
    , .start_date = "2020"
    ) %>%
  group_by(service_line) %>%
  summarize_by_time(
    .date_var = visit_end_date_time
    , .by = "month"
    , visits = n()
  ) %>%
 ungroup() %>%
 ts_plt(
   .date_col = visit_end_date_time
   , .value_col = visits
   , .color_col = service_line
 )

Run the code above in your browser using DataLab