You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: accept data.frame as scale labels #6090
This is a very niche and selfish problem as I'm trying some stuff out in {gguidance}.
It somewhat relates to #6076 a bit, but I'd like the following code:
library(ggplot2)
p<- ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(
breaks=2:7,
labels=data.frame(foo=LETTERS[1:6], bar=1:6)
)
get_guide_data(p, aesthetic="x")
#> Error in `scale_x_continuous()`:#> ! `breaks` and `labels` have different lengths.
To return the following data.frame (note that the .label column is a nested data.frame rather than two separate .label.foo and .label.bar columns):
#> x .value .label.foo .label.bar y#> 1 0.1127946 2 A 1 0#> 2 0.2811448 3 B 2 0#> 3 0.4494949 4 C 3 0#> 4 0.6178451 5 D 4 0#> 5 0.7861953 6 E 5 0#> 6 0.9545455 7 F 6 0
The justification I have for this is that {vctrs} treats data.frames as vectors where rows are treated as elements. We don't really have a good reason to deviate from this behaviour.
Activity
[-]Feature request: accept data.frame labels[/-][+]Feature request: accept data.frame as `labels`[/+][-]Feature request: accept data.frame as `labels`[/-][+]Feature request: accept data.frame as scale `labels`[/+]