Description Usage Arguments Details Value Author(s) Examples
This function will produce two plots. Both of these are moving average plots.
One of the plots is from xts::plot.xts()
and the other a ggplot2
plot. This
is done so that the user can choose which type is best for them. The plots are
stacked so each graph is on top of the other.
1 2 3 4 5 6 7 8 9 |
.data |
The data you want to visualize. This should be pre-processed and
the aggregation should match the |
.date_col |
The data column from the |
.value_col |
The value column from the |
.ts_frequency |
The frequency of the aggregation, quoted, ie. "monthly", anything else will default to weekly, so it is very important that the data passed to this function be in either a weekly or monthly aggregation. |
.main_title |
The title of the main plot. |
.secondary_title |
The title of the second plot. |
.tertiary_title |
The title of the third plot. |
This function expects to take in a data.frame/tibble. It will return a list object so it is a good idea to save the output to a variable and extract from there.
The original time series, the simulated values and a some plots
Steven P. Sanderson II, MPH
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | suppressPackageStartupMessages(library(timetk))
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(tidyquant))
suppressPackageStartupMessages(library(xts))
suppressPackageStartupMessages(library(cowplot))
suppressPackageStartupMessages(library(healthyR.data))
data_tbl <- healthyR_data %>%
select(visit_end_date_time) %>%
summarise_by_time(
.date_var = visit_end_date_time,
.by = "month",
value = n()
) %>%
set_names("date_col","value")
ts_ma_plt(
.data = data_tbl,
.date_col = date_col,
.value_col = value
)
data_tbl <- healthyR_data %>%
select(visit_end_date_time) %>%
summarise_by_time(
.date_var = visit_end_date_time,
.by = "week",
value = n()
) %>%
set_names("date_col","value")
ts_ma_plt(
.data = data_tbl,
.date_col = date_col,
.value_col = value,
.ts_frequency = "week"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.