Description Usage Arguments Value Examples
Plot a time series from a data frame through dygraph's interactive html plot interface
1 2 3 4 5 6 7 8 9 10 |
dt |
data.frame containing the data to plot. It must have a numerical variable, a date variable, and optionally a grouping variable to split the data and plot them as individual time series inside the same 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. Default is RColorBrewer's Paired and Spectral colors concatenated. |
plot_palette_generator |
Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of a dygraph. Default is FALSE. |
A dygraph of the numerical variable specified, optionally split by the values of 'groups'. If static is set to TRUE, it will return a ggplot line plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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))
make_dygraph(dt = dat,
value = 'x',
date = 'date')
make_dygraph(dt = dat,
value = 'x',
groups = 'group',
date = 'date')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.