Description Usage Arguments Value Examples
Plot probability distribution of univariate series across bivariate temporal granularities.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
.data |
a tsibble |
gran1 |
the granularity which is to be placed across facets. Can be column names if required granularity already exists in the tsibble. For example, a column with public holidays which needs to be treated as granularity, can be included here. |
gran2 |
the granularity to be placed across x-axis. Can be column names if required granularity already exists in the tsibble. |
hierarchy_tbl |
A hierarchy table specifying the hierarchy of units and their relationships. |
response |
response variable to be plotted. |
plot_type |
type of distribution plot. Options include "boxplot", "lv" (letter-value), "quantile", "ridge" or "violin". |
quantile_prob |
numeric vector of probabilities with value in [0,1] whose sample quantiles are wanted. Default is set to "decile" plot. |
facet_h |
levels of facet variable for which facetting is allowed while plotting bivariate temporal granularities. |
symmetric |
If TRUE, symmetic quantile area <- is drawn. If FALSE, only quantile lines are drawn instead of area. If TRUE, length of quantile_prob should be odd and ideally the quantile_prob should be a symmetric vector with median at the middle position. |
alpha |
level of transperancy for the quantile area |
threshold_nobs |
the minimum number of observations below which only points would be plotted |
... |
other arguments to be passed for customising the obtained ggplot object. |
a ggplot object which can be customised as usual.
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 | library(tsibbledata)
library(ggplot2)
library(tsibble)
library(lvplot)
library(dplyr)
smart_meter10 %>%
filter(customer_id %in% c("10017936")) %>%
prob_plot(
gran1 = "day_week", gran2 = "hour_day",
response = "general_supply_kwh", plot_type = "quantile",
quantile_prob = c(0.1, 0.25, 0.5, 0.75, 0.9),
symmetric = TRUE,
outlier.colour = "red",
outlier.shape = 2, palette = "Dark2"
)
cricket_tsibble <- cricket %>%
mutate(data_index = row_number()) %>%
as_tsibble(index = data_index)
hierarchy_model <- tibble::tibble(
units = c("index", "over", "inning", "match"),
convert_fct = c(1, 20, 2, 1)
)
cricket_tsibble %>%
prob_plot("inning", "over",
hierarchy_tbl = hierarchy_model,
response = "runs_per_over",
plot_type = "lv"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.