Description Usage Arguments Examples
Add a layer of list_of_na_rle()
to an existing ggplot
1 | layer_na_rle(var, data, ...)
|
var |
A variable that contains |
data |
A data frame. |
... |
Passed to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (!requireNamespace("nycflights13", quietly = TRUE)) {
stop("Please install the nycflights13 package to run these following examples.")
}
library(dplyr, warn.conflicts = FALSE)
weather <- nycflights13::weather
na_runs_wind <- weather %>%
group_by(origin) %>%
summarise_at(
vars(contains("wind")),
~ list_of_na_rle(., index_by = time_hour)
)
library(ggplot2)
ggplot(weather, aes(x = time_hour, y = wind_gust)) +
geom_line(na.rm = TRUE) +
layer_na_rle(wind_gust, data = na_runs_wind, fill = "red", alpha = .5) +
facet_grid(origin ~ .)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.