Description
When I use two ordered factors in a facet_grid
, with as.table = FALSE
in an attempt to get the plot to arrange the facets in a conventional increasing left-to-right, bottom-to-top grid, I get a warning and an error
Error:
! Can't combine `..1$B` <factor<0715c>> and `..2$B` <ordered<08921>>.
Run `rlang::last_error()` to see where the error occurred.
Warning message:
Combining variables of class <ordered> and <ordered> was deprecated in ggplot2 3.4.0.
ℹ Please ensure your variables are compatible before plotting (location: `join_keys()`)
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. ```
Here's a reprex
library(ggplot2)
library(tidyr)
data <- data.frame(
x = rnorm(100), y = rnorm(100),
A = factor(sample(c("tall", "grande", "venti"), 100, replace = TRUE),
levels = c("tall", "grande", "venti"), ordered = TRUE),
B = factor(sample(c("L", "M", "S"), 100, replace = TRUE),
levels = c("S", "M", "L"), ordered = TRUE))
ggplot(data) +
geom_point(aes(x = x, y = y)) +
facet_grid(B ~ A, as.table = TRUE)
# FAILS
ggplot(data) +
geom_point(aes(x = x, y = y)) +
facet_grid(B ~ A, as.table = FALSE)
This seems like a regression in this particular context, since it gives a lot less control over the appearance of the arrangement of the grid of small multiples, even when I am 'doing the right thing' and ordering my factors to get specific effects. Perhaps it was introduced to fix some other problem, but I can't see what it accomplishes in this context.
The error message seems to be from the function utilities::with_ordered_restart
here
Line 664 in 63125db
but it's not clear to me why it should be treated as an error in what is surely a common use-case.
Possibly related to #4180