ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

Errors in prop.test #772

Closed VectorPosse closed 4 years ago

VectorPosse commented 4 years ago

Reprex:

library(openintro)
library(mosaic)
prop.test(~ schtyp, data = hsb2)

Gives error message: Error in tmp[subset] : object of type 'closure' is not subsettable

This worked fine a few days ago before I upgraded to the newest release of mosaic.

I'm using prop.test a lot with my students over the next week or two, so I'd be grateful to know if there's an obvious fix here.

Thanks!

VectorPosse commented 4 years ago

Also, formulas with two terms are giving weird results too:

library(openintro)
library(mosaic)
prop.test(gender ~ schtyp, data = hsb2)

This gives the even more bizarre error: Error in mosaic_formula_q(x, groups = groups, max.slots = 2) : Invalid formula specification. Too many slots (3>2).

luebby commented 4 years ago

Works ok for me:

suppressPackageStartupMessages(library(openintro))
suppressPackageStartupMessages(library(mosaic))
prop.test(~ schtyp, data = hsb2)
#> 
#>  1-sample proportions test with continuity correction
#> 
#> data:  hsb2$schtyp  [with success = public]
#> X-squared = 91.125, df = 1, p-value < 2.2e-16
#> alternative hypothesis: true p is not equal to 0.5
#> 95 percent confidence interval:
#>  0.7800987 0.8864669
#> sample estimates:
#>    p 
#> 0.84
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
#> 
#> locale:
#>  [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
#>  [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
#>  [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] mosaic_1.8.2        ggridges_0.5.2      mosaicData_0.20.1  
#>  [4] ggformula_0.9.4     ggstance_0.3.4      dplyr_1.0.2        
#>  [7] Matrix_1.2-18       ggplot2_3.3.2       lattice_0.20-41    
#> [10] openintro_2.0.0     usdata_0.1.0        cherryblossom_0.1.0
#> [13] airports_0.1.0     
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.1.0  xfun_0.18         purrr_0.3.4       splines_4.0.2    
#>  [5] colorspace_1.4-1  vctrs_0.3.4       generics_0.0.2    htmltools_0.5.0  
#>  [9] yaml_2.2.1        rlang_0.4.7       pillar_1.4.6      withr_2.3.0      
#> [13] glue_1.4.2        tweenr_1.0.1      plyr_1.8.6        lifecycle_0.2.0  
#> [17] mosaicCore_0.8.0  stringr_1.4.0     munsell_0.5.0     gtable_0.3.0     
#> [21] htmlwidgets_1.5.2 evaluate_0.14     knitr_1.30        crosstalk_1.1.0.1
#> [25] highr_0.8         broom_0.7.1       Rcpp_1.0.5        readr_1.4.0      
#> [29] scales_1.1.1      backports_1.1.10  leaflet_2.0.3     farver_2.0.3     
#> [33] gridExtra_2.3     hms_0.5.3         ggforce_0.3.2     digest_0.6.25    
#> [37] stringi_1.5.3     ggrepel_0.8.2     polyclip_1.10-0   grid_4.0.2       
#> [41] tools_4.0.2       magrittr_1.5      tibble_3.0.3      ggdendro_0.1.22  
#> [45] crayon_1.3.4      tidyr_1.1.2       pkgconfig_2.0.3   MASS_7.3-53      
#> [49] ellipsis_0.3.1    rmarkdown_2.4     R6_2.4.1          compiler_4.0.2

Created on 2020-10-08 by the reprex package (v0.3.0)

Please check if mosaic and mosaicCore are both updated, see https://github.com/ProjectMOSAIC/mosaicCore/issues/32

VectorPosse commented 4 years ago

Okay, yep, that was the problem. I had updated mosaicCore, but not mosaic. My bad. Thanks for the quick response.

On Wed, Oct 7, 2020 at 11:46 PM Karsten Luebke notifications@github.com wrote:

Works ok for me:

suppressPackageStartupMessages(library(openintro)) suppressPackageStartupMessages(library(mosaic)) prop.test(~ schtyp, data = hsb2)#> #> 1-sample proportions test with continuity correction#> #> data: hsb2$schtyp [with success = public]#> X-squared = 91.125, df = 1, p-value < 2.2e-16#> alternative hypothesis: true p is not equal to 0.5#> 95 percent confidence interval:#> 0.7800987 0.8864669#> sample estimates:#> p #> 0.84 sessionInfo()#> R version 4.0.2 (2020-06-22)#> Platform: x86_64-pc-linux-gnu (64-bit)#> Running under: Ubuntu 18.04.5 LTS#> #> Matrix products: default#> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1#> #> locale:#> [1] LC_CTYPE=de_DE.UTF-8 LC_NUMERIC=C #> [3] LC_TIME=de_DE.UTF-8 LC_COLLATE=de_DE.UTF-8 #> [5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=de_DE.UTF-8 #> [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C #> [9] LC_ADDRESS=C LC_TELEPHONE=C #> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C #> #> attached base packages:#> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages:#> [1] mosaic_1.8.2 ggridges_0.5.2 mosaicData_0.20.1 #> [4] ggformula_0.9.4 ggstance_0.3.4 dplyr_1.0.2 #> [7] Matrix_1.2-18 ggplot2_3.3.2 lattice_0.20-41 #> [10] openintro_2.0.0 usdata_0.1.0 cherryblossom_0.1.0#> [13] airports_0.1.0 #> #> loaded via a namespace (and not attached):#> [1] tidyselect_1.1.0 xfun_0.18 purrr_0.3.4 splines_4.0.2 #> [5] colorspace_1.4-1 vctrs_0.3.4 generics_0.0.2 htmltools_0.5.0 #> [9] yaml_2.2.1 rlang_0.4.7 pillar_1.4.6 withr_2.3.0 #> [13] glue_1.4.2 tweenr_1.0.1 plyr_1.8.6 lifecycle_0.2.0 #> [17] mosaicCore_0.8.0 stringr_1.4.0 munsell_0.5.0 gtable_0.3.0 #> [21] htmlwidgets_1.5.2 evaluate_0.14 knitr_1.30 crosstalk_1.1.0.1#> [25] highr_0.8 broom_0.7.1 Rcpp_1.0.5 readr_1.4.0 #> [29] scales_1.1.1 backports_1.1.10 leaflet_2.0.3 farver_2.0.3 #> [33] gridExtra_2.3 hms_0.5.3 ggforce_0.3.2 digest_0.6.25 #> [37] stringi_1.5.3 ggrepel_0.8.2 polyclip_1.10-0 grid_4.0.2 #> [41] tools_4.0.2 magrittr_1.5 tibble_3.0.3 ggdendro_0.1.22 #> [45] crayon_1.3.4 tidyr_1.1.2 pkgconfig_2.0.3 MASS_7.3-53 #> [49] ellipsis_0.3.1 rmarkdown_2.4 R6_2.4.1 compiler_4.0.2

Created on 2020-10-08 by the reprex package https://reprex.tidyverse.org (v0.3.0)

Please check if mosaic and mosaicCore are both updated, see ProjectMOSAIC/mosaicCore#32 https://github.com/ProjectMOSAIC/mosaicCore/issues/32

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ProjectMOSAIC/mosaic/issues/772#issuecomment-705344359, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3M3H6B5U3ZVNS7ER7GQWTSJVG5FANCNFSM4SIHMNCA .