facet_strata {brolgar} | R Documentation |
Facet data into groups to facilitate exploration
Description
This function requires a tbl_ts
object, which can be created with
tsibble::as_tsibble()
. Under the hood, facet_strata
is powered by
stratify_keys()
.
Usage
facet_strata(
n_strata = 12,
along = NULL,
fun = mean,
nrow = NULL,
ncol = NULL,
scales = "fixed",
shrink = TRUE,
strip.position = "top"
)
Arguments
n_strata |
number of groups to create |
along |
variable to stratify along. This groups by each |
fun |
summary function. Default is mean. |
nrow , ncol |
Number of rows and columns. |
scales |
Should scales be fixed ( |
shrink |
If |
strip.position |
By default, the labels are displayed on the top of
the plot. Using |
Value
a ggplot object
Examples
library(ggplot2)
ggplot(heights,
aes(x = year,
y = height_cm,
group = country)) +
geom_line() +
facet_strata()
ggplot(heights,
aes(x = year,
y = height_cm,
group = country)) +
geom_line() +
facet_wrap(~continent)
ggplot(heights,
aes(x = year,
y = height_cm,
group = country)) +
geom_line() +
facet_strata(along = year)
library(dplyr)
heights %>%
key_slope(height_cm ~ year) %>%
right_join(heights, ., by = "country") %>%
ggplot(aes(x = year,
y = height_cm)) +
geom_line(aes(group = country)) +
geom_smooth(method = "lm") +
facet_strata(along = .slope_year)