Closed
Description
I've been starting to make more and more use of data frames with class c("tbl", "data.frame") due to the nice formatting pillar provides but ran in to a ggplot2 issue today that I'd appreciate thoughts on before I raise over there (apologies for this but due to your "ownership" of tbl I thought you'd have an opinion and wanted to confirm my understanding of how you view the tbl class).
If you run the following in an environment with no dplyr installation it errors:
library(ggplot2)
x <- y <- seq_len(2L)
dat <- data.frame(x,y)
class(dat) <- c("tbl", class(dat))
ggplot(dat,aes(x,y))+geom_col()
#> Error in `fortify()`:
#> ! The package `dplyr` is required to work with `tbl` objects
Created on 2022-03-25 by the reprex package (v2.0.1)
This is due to this line in ggplot2. This feels odd to me. My inclination is that ggplot2 should either:
- have specific methods for different classes they want to support and dispatch to the data frame method by default; or
- Take dplyr to be a hard dependency if they do want to call
dplyr::collect()
on tbls.
Appreciate any thoughts you may have.
Metadata
Metadata
Assignees
Labels
No labels