Unless tibble is unloaded, dev version breaks (some) standard ggplot2 plots
Closed this issue · 4 comments
Running 2.2.1.900 of ggplot2
and 0.1.2.900 of ggmosaic
breaks some ggplot2 plots that rely on operations on factors (e.g. geom_tile(aes(fill = success))
, where success
is a factor).
Unloading tibble
(which requires unloading ggmosaic
, ggplot2
, and all of tidyverse
dependencies) with unloadNamespace
is the only way to restore functionality. Unloading everything but tibble
does not. Loading tibble
on its own does not break things.
Installing cutting-edge version of tibble doesn't help; the problem occurs with the latest stable CRAN version as well. This report is generated from a Mac with packrat, but I continue to encounter it on x64 Windows 7 without packrat.
Reprex to follow.
> devtools::session_info()
Session info ----------------------------------------------------------------------------
setting value
version R version 3.4.1 (2017-06-30)
system x86_64, darwin16.6.0
ui RStudio (1.0.153)
language (EN)
collate en_US.UTF-8
tz America/New_York
date 2017-08-11
Packages --------------------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.4.1)
backports 1.1.0 2017-05-22 CRAN (R 3.4.1)
base * 3.4.1 2017-07-07 local
base64enc 0.1-3 2015-07-28 CRAN (R 3.4.1)
bindr 0.1 2016-11-13 CRAN (R 3.4.1)
bindrcpp * 0.2 2017-06-17 CRAN (R 3.4.1)
broom * 0.4.2 2017-02-13 CRAN (R 3.4.1)
car * 2.1-5 2017-07-04 CRAN (R 3.4.1)
cellranger 1.1.0 2016-07-27 CRAN (R 3.4.1)
colorspace 1.3-2 2016-12-14 CRAN (R 3.4.1)
compiler 3.4.1 2017-07-07 local
cowplot * 0.8.0 2017-07-30 CRAN (R 3.4.1)
data.table 1.10.4 2017-02-01 CRAN (R 3.4.1)
datasets * 3.4.1 2017-07-07 local
devtools 1.13.3 2017-08-02 CRAN (R 3.4.1)
digest 0.6.12 2017-01-27 CRAN (R 3.4.1)
dplyr * 0.7.2 2017-07-20 CRAN (R 3.4.1)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)
forcats * 0.2.0 2017-01-23 CRAN (R 3.4.1)
foreign 0.8-69 2017-06-22 CRAN (R 3.4.1)
gdata 2.18.0 2017-06-06 CRAN (R 3.4.1)
ggmosaic * 0.1.2.9000 2017-08-11 Github (haleyjeppson/ggmosaic@cf32577)
ggplot2 * 2.2.1.9000 2017-08-11 Github (tidyverse/ggplot2@53a22cd)
glue 1.1.1 2017-06-21 CRAN (R 3.4.1)
gmodels 2.16.2 2015-07-22 CRAN (R 3.4.1)
graphics * 3.4.1 2017-07-07 local
grDevices * 3.4.1 2017-07-07 local
grid 3.4.1 2017-07-07 local
gtable 0.2.0 2016-02-26 CRAN (R 3.4.1)
gtools 3.5.0 2015-05-29 CRAN (R 3.4.1)
haven 1.1.0 2017-07-09 CRAN (R 3.4.1)
highr 0.6 2016-05-09 CRAN (R 3.4.1)
hms 0.3 2016-11-22 CRAN (R 3.4.1)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.1)
htmlwidgets 0.9 2017-07-10 CRAN (R 3.4.1)
httr 1.2.1 2016-07-03 CRAN (R 3.4.1)
jsonlite 1.5 2017-06-01 CRAN (R 3.4.1)
kableExtra * 0.4.0 2017-08-06 CRAN (R 3.4.1)
knitr 1.16 2017-05-18 CRAN (R 3.4.1)
labeling 0.3 2014-08-23 CRAN (R 3.4.1)
lattice 0.20-35 2017-03-25 CRAN (R 3.4.1)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.4.1)
lme4 1.1-13 2017-04-19 CRAN (R 3.4.1)
lubridate 1.6.0 2016-09-13 CRAN (R 3.4.1)
magrittr 1.5 2014-11-22 CRAN (R 3.4.1)
MASS 7.3-47 2017-02-26 CRAN (R 3.4.1)
Matrix 1.2-10 2017-05-03 CRAN (R 3.4.1)
MatrixModels 0.4-1 2015-08-22 CRAN (R 3.4.1)
memoise 1.1.0 2017-04-21 CRAN (R 3.4.1)
methods * 3.4.1 2017-07-07 local
mgcv 1.8-17 2017-02-08 CRAN (R 3.4.1)
minqa 1.2.4 2014-10-09 CRAN (R 3.4.1)
mnormt 1.5-5 2016-10-15 CRAN (R 3.4.1)
modelr 0.1.0 2016-08-31 CRAN (R 3.4.1)
munsell 0.4.3 2016-02-13 CRAN (R 3.4.1)
nlme 3.1-131 2017-02-06 CRAN (R 3.4.1)
nloptr * 1.0.4 2014-08-04 CRAN (R 3.4.1)
nnet 7.3-12 2016-02-02 CRAN (R 3.4.1)
packrat 0.4.8-1 2016-09-07 CRAN (R 3.4.1)
papeR * 1.0-2 2017-02-16 CRAN (R 3.4.1)
parallel 3.4.1 2017-07-07 local
pbkrtest 0.4-7 2017-03-15 CRAN (R 3.4.1)
pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.1)
plotly 4.7.1 2017-07-29 CRAN (R 3.4.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.4.1)
productplots * 0.1.1 2016-07-02 CRAN (R 3.4.1)
psych 1.7.5 2017-05-03 CRAN (R 3.4.1)
purrr * 0.2.3 2017-08-02 cran (@0.2.3)
quantreg 5.33 2017-04-18 CRAN (R 3.4.1)
R6 2.2.2 2017-06-17 CRAN (R 3.4.1)
Rcpp 0.12.12 2017-07-15 CRAN (R 3.4.1)
readr * 1.1.1 2017-05-16 CRAN (R 3.4.1)
readxl 1.0.0 2017-04-18 CRAN (R 3.4.1)
reshape2 1.4.2 2016-10-22 CRAN (R 3.4.1)
rlang 0.1.2 2017-08-09 cran (@0.1.2)
rmarkdown 1.6 2017-06-15 CRAN (R 3.4.1)
rprojroot 1.2 2017-01-16 CRAN (R 3.4.1)
rvest 0.3.2 2016-06-17 CRAN (R 3.4.1)
scales 0.4.1.9002 2017-08-11 Github (hadley/scales@9834874)
SparseM 1.77 2017-04-23 CRAN (R 3.4.1)
splines 3.4.1 2017-07-07 local
stats * 3.4.1 2017-07-07 local
stringi 1.1.5 2017-04-07 CRAN (R 3.4.1)
stringr * 1.2.0 2017-02-18 CRAN (R 3.4.1)
tibble * 1.3.3.9001 2017-08-11 Github (tidyverse/tibble@cd6337e)
(but also tibble * 1.3.3 2017-05-28 Github (cran/tibble@ad03076))
tidyr * 0.6.3 2017-05-15 CRAN (R 3.4.1)
tidyverse * 1.1.1 2017-01-27 CRAN (R 3.4.1)
tools 3.4.1 2017-07-07 local
utils * 3.4.1 2017-07-07 local
viridisLite 0.2.0 2017-03-24 CRAN (R 3.4.1)
withr 2.0.0 2017-08-11 Github (jimhester/withr@190d293)
xml2 1.1.1 2017-01-24 CRAN (R 3.4.1)
xtable * 1.8-2 2016-02-05 CRAN (R 3.4.1)
yaml 2.1.14 2016-11-12 CRAN (R 3.4.1)
Not a reprex, but an example of the error I encounter. phase
, ID
, success
and pilot
are all factors:
> acqrev_plot <- ggplot(data = acquired_reversed_long,
+ aes(x = phase,
+ y = ID,
+ fill = success)) +
+ geom_tile() + xlab('Phase') + ylab('Participant') +
+ ggtitle('Has the participant acquired / reversed in the given phase?') +
+ facet_grid(pilot ~ ., scales = 'free_y', space = 'free_y') +
+ scale_fill_discrete(name = c()) + guides(fill = guide_legend(reverse = TRUE)) +
+ theme(legend.position="bottom")
> acqrev_plot
as.tibble.list
as.tibble.list
as.tibble.list
as.tibble.list
Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, :
‘range’ not meaningful for factors
This is not geom_tile
-specific - barplots fail, too.
Here's the reprex - as you can see, this breaks even the most basic ggplot2 operations:
library(ggplot2)
ggplot(data = data.frame(a = 1:2, b = 3:4), aes(x = a, y = b)) + geom_point()
library(ggmosaic)
#> Loading required package: tibble
#> Loading required package: productplots
#>
#> Attaching package: 'ggmosaic'
#> The following objects are masked from 'package:productplots':
#>
#> ddecker, hspine, mosaic, prodcalc, spine, vspine
ggplot(data = data.frame(a = 1:2, b = 3:4), aes(x = a, y = b)) + geom_point()
#> as.tibble.list
#> Error: geom_point requires the following missing aesthetics: x
I can't run this on my own machine right now, but after reading more about namespaces, I think I know what's going on. My hypothesis is that exporting as_tibble.list
screws things up by overruling the original S3 method from tibble
and doing so incompatibly. Given the namespace magic that @heike is doing in c97a287 in order to get the vignette working, I imagine this was necessary to get ggplot2 to cooperate.
Looking at the history of as_tibble.R
, I can't tell what, if anything, changed. I do wonder if at some point, this breakage wasn't occurring. Alternatively, it's possible that due to clean separation between development environments, @heike never attempted to graph any non-mosaic plots with this edit and so never ran into this issue? I can't tell from commit history or issue tracker what exactly prompted the changes.
I hope I'll have some time next week to look into possible fixes. At this point, it seems like there are two broad possibilities:
- Rewriting
ggmosaic::as_tibble.list
so that it doesn't screw up non-mosaic inputs, - Rewriting
ggmosaic`` data structures so that they don't get screwed up by
tibble::as_tibble.list`.
this has been fixed.