fab_tod | R Documentation |
In a normal setting it may be that observations that occur at night are
indicative of data fabrication. fab_tod
(short for fabrication, time
of day), produces a plot that may help to identify problems. Customs vary in
different countries, so that should be accounted for when interpreting these
figures.
fab_tod(
data,
var,
by = NULL,
dow_fmt = "%a",
output = c("list", "facet"),
col_poly = "black",
x_poly = c(8.5, 21.5),
col_bars = "grey"
)
data |
data frame containing |
var |
string. Name of variable containing relevant datetimes |
by |
string. Name of variable denoting grouping |
dow_fmt |
format for day of week |
output |
output format |
col_poly |
colour to use for the region indicating possible fabrication |
x_poly |
x coordinates for the start and end of the region indicating possible fabrication |
col_bars |
colour to use for bars indicating counts |
Due to a limitation of faceting plots with polar coordinates, faceted plots all have the same y coordinate (equivalent to fixed axes). To free the coordinate system, use the list output (default) and wrap them together using e.g. patchwork, possibly applying some customizations in advance.
list or ggplot2 object
set.seed(234)
dat <- data.frame(
x = lubridate::ymd_h("2020-05-01 14") + 60^2*sample(0:20, 40, TRUE),
by = c(rep(1, 10), rep(2, 30))
)
dat %>% fab_tod("x")
dat %>% fab_tod("x") + theme_kpitools()
dat %>% fab_tod("x", "by")
#faceted of plots
dat %>% fab_tod("x", "by", output = "facet")
#with patchwork
patchwork::wrap_plots(dat %>% fab_tod("x", "by"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.