ggbraid
ggbraid copied to clipboard
Provide more informative error message when all NAs are removed
library(tidyverse)
library(ggbraid)
df_long <- tibble(
x = c(1:8, 1:8),
y = c(2, 5, 6, 3, 7, 1, 4, 2, 1, 6, 5, 3, 3, 2, 1, 0),
z = c(rep("a", 8), rep("b", 8))
)
df_wide <- pivot_wider(df_long, names_from = z, values_from = y)
df_wide
# A tibble: 16 × 3
x a b
<dbl> <dbl> <dbl>
1 1 2 NA
2 2 5 NA
3 3 6 NA
4 4 3 NA
5 5 7 NA
6 6 1 NA
7 7 4 NA
8 8 2 NA
9 1.5 NA 1
10 2.5 NA 6
11 3.5 NA 5
12 4.5 NA 3
13 5.5 NA 3
14 6.5 NA 2
15 7.5 NA 1
16 8.5 NA 0
ggplot() +
geom_line(aes(x, y, linetype = z), data = df_long) +
geom_braid(aes(x, ymin = a, ymax = b, fill = a <= b), data = df_wide, alpha = 0.6, method = "line", na.rm=TRUE) +
guides(linetype = "none", fill = "none")
Warning messages:
1: Ignoring unknown parameters: direction
2: In max(data$group) : no non-missing arguments to max; returning -Inf
3: Computation failed in `stat_braid()`:
'to' must be a finite number