add_dygraph {chronicle} | R Documentation |
Add a dygraph to a chronicle report
Description
Add a dygraph to a chronicle report
Usage
add_dygraph(
report = "",
dt,
value,
date,
groups = NULL,
y_axis_label = NULL,
plot_palette = NULL,
plot_palette_generator = NULL,
dygraph_title = NULL,
title_level = 2,
echo = FALSE,
message = FALSE,
warning = FALSE,
fig_width = NULL,
fig_height = NULL
)
Arguments
report |
Character string containing all the R Markdown chunks previously added. Default is ”, an empty report. |
dt |
Data to plot |
value |
Name of the column of the data frame containing the numerical variables of the time series. |
date |
Name of the column containing the date variable. It must be already a date or time object. |
groups |
Name of the columns containing the different groups. |
y_axis_label |
Label for the y axis. x axis is the date (or time) so it is not needed |
plot_palette |
Character vector of hex codes specifying the colors to use on the plot. |
plot_palette_generator |
Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required. |
dygraph_title |
Title for the Rmarkdown section containing the dygraph |
title_level |
Level of the section title of this plot (ie, number of # on Rmarkdown syntax.) |
echo |
Whether to display the source code in the output document. Default is FALSE. |
message |
Whether to preserve messages on rendering. Default is FALSE. |
warning |
Whether to preserve warnings on rendering. Default is FALSE. |
fig_width |
Width of the plot (in inches). |
fig_height |
Height of the plot (in inches). |
Value
An R Markdown file as a character string, now containing a chunk for the specified dygraph.
Examples
dat <- data.frame(x = c(rnorm(100, 2, 4),
rnorm(100, 6, 1),
rnorm(100, 8, 2)),
group = c(rep('A', 100),
rep('B', 100),
rep('C', 100)),
date = rep(seq(as.Date("2020-01-01"),
as.Date("2020-04-09"),
'days'),
3))
html_report <- add_dygraph(report = '',
dt = dat,
value = 'x',
date = 'date')
cat(html_report)