ProjectMOSAIC / ggformula

Provides a formula interface to 'ggplot2' graphics.
Other
39 stars 11 forks source link

issue with Error in find_subclass("Geom", geom, parent.frame()) : could not find function "find_subclass" #99

Closed nicholasjhorton closed 6 years ago

nicholasjhorton commented 6 years ago

A colleague of mine is also having this issue. Any guidance would be welcomed.

library(mosaic) Loading required package: dplyr

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Loading required package: lattice Loading required package: ggformula Loading required package: ggplot2

New to ggformula? Try the tutorials: learnr::run_tutorial("introduction", package = "ggformula") learnr::run_tutorial("refining", package = "ggformula") Loading required package: mosaicData Loading required package: Matrix

The 'mosaic' package masks several functions from core packages in order to add additional features. The original behavior of these functions should not be affected by this.

Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.

Attaching package: ‘mosaic’

The following object is masked from ‘package:Matrix’:

mean

The following object is masked from ‘package:ggplot2’:

stat

The following objects are masked from ‘package:dplyr’:

count, do, tally

The following objects are masked from ‘package:stats’:

binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test, quantile,
sd, t.test, var

The following objects are masked from ‘package:base’:

max, mean, min, prod, range, sample, sum

Warning message: package ‘dplyr’ was built under R version 3.5.1

gf_histogram(~ age, data = HELPrct) Error in find_subclass("Geom", geom, parent.frame()) : could not find function "find_subclass" sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.5

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] mosaic_1.3.0 Matrix_1.2-14 mosaicData_0.17.0 ggformula_0.8.0
[5] ggplot2_3.0.0 lattice_0.20-35 dplyr_0.7.6

loaded via a namespace (and not attached): [1] Rcpp_0.12.17 pillar_1.2.3 compiler_3.5.0 plyr_1.8.4 bindr_0.1.1
[6] tools_3.5.0 tibble_1.4.2 gtable_0.2.0 nlme_3.1-137 pkgconfig_2.0.1 [11] rlang_0.2.1 psych_1.8.4 yaml_2.1.19 parallel_3.5.0 ggdendro_0.1-20 [16] bindrcpp_0.2.2 gridExtra_2.3 withr_2.1.2 stringr_1.3.1 grid_3.5.0
[21] tidyselect_0.2.4 mosaicCore_0.6.0 glue_1.2.0 R6_2.2.2 foreign_0.8-70
[26] tidyr_0.8.1 purrr_0.2.5 reshape2_1.4.3 magrittr_1.5 scales_0.5.0
[31] MASS_7.3-50 splines_3.5.0 assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 [36] stringi_1.2.3 lazyeval_0.2.1 munsell_0.5.0 broom_0.4.5

nicholasjhorton commented 6 years ago

This is nasty. I've not been able to figure out a workaround (and another colleague, on Windows, has reported the same issue). I've tried upgrading to R 3.5.1. Any thoughts or suggestions?

luebby commented 6 years ago

Just a first hint: last year there was a function called find_subclass() https://github.com/tidyverse/ggplot2/blob/e1bd0e621c903fc7550f6a250b22c36c9b578545/R/layer.r: Line 324. But now I am looking for camelize() which I have not found yet. (Problem remains with R 3.5.1 on Ubuntu)

nicholasjhorton commented 6 years ago

This is now resolved once I run the development version of ggformula:

devtools::install_github("ProjectMOSAIC/ggformula", ref = "beta")

Is something awry on the CRAN version?

rpruim commented 6 years ago

I don't think it has anything to do with master/CRAN vs beta since I don't see any changes in beta that would appear to have anything to do with this and things work fine for me when I revert to master.

Since I can't recreate this, it's hard to debug on my end. Here are some diagnostic things to try on a machine having trouble:

I'd also be interested in seeing a traceback() if after all this you can recreate the error.

kostis-christodoulou commented 6 years ago

I had the exact same issue and it all started when I upgraded to ggplot2 version 3 that came out the other day. The only way I could get ggformula to play with ggplot was to 'downgrade' to ggplot 2.2.1.

rpruim commented 6 years ago

@kostis-christodoulou, can you recreate the problem by reinstalling the new ggplot2?

If that does break, can you try something? After installing the new ggplot2, reinstall ggformula and tell me weather that changes behavior.

(I'm running new versions of both ggplot2 and ggformula without any issues -- and the CRAN checks all pass at https://cran.r-project.org/web/checks/check_results_ggformula.html, so I need some assistance from someone with a problematic set up to isolate where it is coming from.)

kostis-christodoulou commented 6 years ago

Yes, this worked

Recap of what I have done. I am on R 3.5.1 and mosaic 1.3.0

  1. When I used ggformula 0.8.0 and the 'old' ggplot (version 2.2.1) , I was able to get graphs.

  2. When I upgraded ggplot to 3.0, I could only get numerical summaries (favstats, etc) through mosaic, but no graphs, so the problem persists. When trying to run a gf_point I got the same error message Error in find_subclass("Geom", geom, parent.frame()) : could not find function "find_subclass"

  3. Having upgraded to ggplot 3.0 first and then reinstalling ggformula 0.8.0, I was able to get graphs (gf_point, gf_boxplot, etc)

Why would ggplot have to install before ggformula?

rpruim commented 6 years ago

Thanks. This problem will go away with the next release of mosaic, but for this one, we had to get a new version of mosaic to CRAN before the new version of ggplot2 was there, so we couldn't properly depend on ggplot2 (>= 3.0) as we will from now on.

The issue is that several of the plotting functions are created using a function factory. This happens when ggformula is installed, and in that code there is a test for the version of ggplot2. It would have been better (but more complicated) to push that check into the resulting functions, I guess. But the whole check will be going away in favor of the stronger dependency.

I just pushed to github my local version that has the ggplot2 (>= 3.0) dependency. That should force the new version of ggplot2 to be installed first.