ggforce icon indicating copy to clipboard operation
ggforce copied to clipboard

facet_zoom fails on grouped input data

Open Zedseayou opened this issue 5 years ago • 1 comments

Found this out when trying to use facet_zoom on what I thought was a very simple table. facet_zoom doesn't appear to ignore grouping on the input data, which causes it to throw an error that seems to be from cbind_all. This can easily be worked around by ungrouping, but often happens when I create new variables in a pipe before piping to ggplot and feels unintuitive since usually ggplot2 ignores grouping. Using the readme example, to show it works fine without grouping:

library(dplyr)
library(ggforce)
#> Loading required package: ggplot2
iris %>%
  group_by(Species) %>% # mutate(x = Sepal.Length / sum(Sepal.Length))
  ggplot(aes(Petal.Length, Petal.Width, colour = Species)) +
  geom_point() +
  facet_zoom(x = Species == "setosa")
#> Error: Argument 2 must be length 150, not 1

iris %>%
  ggplot(aes(Petal.Length, Petal.Width, colour = Species)) +
  geom_point() +
  facet_zoom(x = Species == "setosa")

Zedseayou avatar Oct 15 '19 00:10 Zedseayou

Thanks a lot ! I couldn't figure out why I had this error ! Turns out that the grouping remains effective even after summarise()

nibortolum avatar Mar 15 '20 12:03 nibortolum

This appears to be fixed

thomasp85 avatar Sep 02 '22 10:09 thomasp85