Skip to content

Warning when using facet_grid() with ordered factors #6479

Open
@lgaborini

Description

@lgaborini

A bit of a niche issue, the plotting works fine, and the factor ordering is also retained, but I signal it nevertheless.

library(ggplot2)

df <- mtcars |>
  dplyr::mutate(
    dplyr::across(c(gear, carb), ordered)
  )

df |>
  ggplot(aes(mpg, wt)) +
  geom_point() +
  facet_grid(
    vars(gear), vars(carb),
    margins = TRUE
  )
#> Warning: Combining variables of class <ordered> and <factor> was deprecated in ggplot2
#> 3.4.0.
#> ℹ Please ensure your variables are compatible before plotting (location:
#>   `reshape_add_margins()`)
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: Combining variables of class <factor> and <ordered> was deprecated in ggplot2
#> 3.4.0.
#> ℹ Please ensure your variables are compatible before plotting (location:
#>   `reshape_add_margins()`)
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

Created on 2025-05-26 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    messagesrequests for improvements to error, warning, or feedback messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions