Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facet_grid with ordered factors and drop = FALSE causes deprecation warning #5666

Closed
ibuiltthis opened this issue Jan 28, 2024 · 0 comments · Fixed by #5704
Closed

facet_grid with ordered factors and drop = FALSE causes deprecation warning #5666

ibuiltthis opened this issue Jan 28, 2024 · 0 comments · Fixed by #5704
Labels
facets 💎 messages requests for improvements to error, warning, or feedback messages
Milestone

Comments

@ibuiltthis
Copy link

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)
@teunbrand teunbrand added facets 💎 messages requests for improvements to error, warning, or feedback messages labels Feb 2, 2024
@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
facets 💎 messages requests for improvements to error, warning, or feedback messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants