Closed
Description
I found a problem with faceting in ggplot
I expected the plot to be produced with no warnings. The plot does work correctly as this is just a warning but will probably break in the future.
Here is the code to reproduce the bug:
library(tidyverse)
my_data <- tibble(
things = factor(c("shoe", "sock", "bed", "curtain"), ordered = TRUE)
)
my_data_filtered <- my_data |> filter(things != "curtain")
ggplot(my_data_filtered) +
geom_bar(
aes(x = 1)
) +
facet_grid(
rows = vars(things),
drop = FALSE
)
# Warning message:
# Combining variables of class <ordered> and <factor> 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.
lifecycle::last_lifecycle_warnings()
# [[1]]
# <warning/lifecycle_warning_deprecated>
# Warning:
# Combining variables of class <ordered> and <factor> was deprecated in ggplot2 3.4.0.
# ℹ Please ensure your variables are compatible before plotting (location: `join_keys()`)
# ---
# Backtrace:
# ▆
# 1. ├─base (local) `<fn>`(x)
# 2. ├─ggplot2:::print.ggplot(x)
# 3. │ ├─ggplot2::ggplot_build(x)
# 4. │ └─ggplot2:::ggplot_build.ggplot(x)
# 5. │ └─layout$setup(data, plot$data, plot$plot_env)
# 6. │ └─ggplot2 (local) setup(..., self = self)
# 7. │ └─base::lapply(...)
# 8. │ └─ggplot2 (local) FUN(X[[i]], ...)
# 9. │ └─ggplot2::map_data(...)
# 10. │ └─ggplot2:::join_keys(facet_vals, layout, by = vars)
# 11. │ └─ggplot2:::vec_rbind0(x[by], y[by])
# 12. │ ├─ggplot2:::with_ordered_restart(...)
# 13. │ │ └─base::withCallingHandlers(...)
# 14. │ └─vctrs::vec_rbind(..., .error_call = .error_call)
# 15. │ └─vctrs (local) `<fn>`()
# 16. │ └─vctrs:::vec_ptype2.ordered.factor(...)
# 17. │ └─vctrs::vec_default_ptype2(x, y, ...)
# 18. │ ├─base::withRestarts(...)
# 19. │ │ └─base (local) withOneRestart(expr, restarts[[1L]])
# 20. │ │ └─base (local) doWithOneRestart(return(expr), restart)
# 21. │ └─vctrs::stop_incompatible_type(...)
# 22. │ └─vctrs:::stop_incompatible(...)
# 23. │ └─vctrs:::stop_vctrs(...)
# 24. │ └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
# 25. │ └─rlang:::signal_abort(cnd, .file)
# 26. │ └─base::signalCondition(cnd)
# 27. └─ggplot2 (local) `<fn>`(`<vctrs__2>`)
# 28. └─ggplot2:::deprecate_soft0("3.4.0", I(msg), details = desc)