tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.39k stars 2k forks source link

Restore `as.table` #5900

Closed teunbrand closed 1 month ago

teunbrand commented 1 month ago

This PR aims to fix #5898.

Briefly, some extensions require as.table to be present, which this PR restores. Instead of incorporating as.table in dir in the constructor, we now do this in wrap_layout().

It pains me a little bit, as I was quite pleased that we could get rid of as.table as a parameter before and now we have to bring back this vestigial parameter.

teunbrand commented 1 month ago

A reprex with this PR:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
library(deeptime)

df <- data.frame(x = 1:10, y = 1:10, period = c("Permian", "Triassic"))
ggplot(df) +
  geom_point(aes(x, y)) +
  facet_wrap_color(vars(period), colors = periods)

Created on 2024-05-21 with reprex v2.1.0

Whereas on main, the same code gives:

#> Error in `data_frame()` at ggplot2/R/utilities.R:351:16:
#> ! Can't recycle `ROW` (size 0) to size 2.
thomasp85 commented 1 month ago

could we deprecate it gracefully instead of committing to having it around for eternity?

teunbrand commented 1 month ago

I'd like to but this is proving to be a bit more finnicky that I anticipated.

teunbrand commented 1 month ago

closing this in favour of #5907