Add a layer of list_of_na_rle() to an existing ggplot

layer_na_rle(var, data, ...)

Arguments

var

A variable that contains list_of_na_rle().

data

A data frame.

...

Passed to ggplot2::geom_rect().

Examples

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 ~ .)