sts_ggplot | R Documentation |
"sts"
Objects Using ggplot2
A simple ggplot2 variant of stsplot_time
,
based on a “tidy” version of the "sts"
object via
tidy.sts
.
It uses a date axis and thus only works for time series indexed by
dates or with a standard frequency (daily, (bi-)weekly, or monthly).
autoplot.sts(object, population = FALSE, units = NULL,
as.one = FALSE, scales = "fixed", width = NULL, ...)
object |
an object of class |
population |
logical indicating whether |
units |
optional integer or character vector to select the units
(=columns of |
as.one |
logical indicating if all time series should be plotted
in one panel with |
scales |
passed to |
width |
bar width, passed to |
... |
unused (argument of the generic). |
a "ggplot"
object.
Sebastian Meyer
stsplot_time
for the traditional plots.
## compare traditional plot() with ggplot2-based autoplot.sts()
if (requireNamespace("ggplot2")) {
data("measlesDE")
plot(measlesDE, units = 1:2)
autoplot.sts(measlesDE, units = 1:2)
}
## weekly incidence: population(measlesDE) gives population fractions,
## which we need to multiply by the total population
if (require("ggplot2", quietly = TRUE)) {
autoplot.sts(measlesDE, population = 1000000/82314906) +
ylab("Weekly incidence [per 1'000'000 inhabitants]")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.