IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis 📊📣
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
1.97k stars 184 forks source link

"Error: Names must be unique" in ggwithinplot #396

Closed XiaoyuZeng closed 4 years ago

XiaoyuZeng commented 4 years ago

The problem:

I tried to run a function (ggwithinplot) to plot data in ggstatsplot. But it took a long time to run this function, and nothing turned out:

image

So I shut down this function while it was running. I tried waiting. It didn't work. So this problem was not a time issue.

After that, I was wondering whether it was due to that I got a large number of data points (N=2000). So I tried another sample that includes 250 data points. And this time, I got this error: "ERROR: Names must be unique."

ERROR: Names must be unique. Backtrace: 
1. ggstatsplot::ggwithinstats(...) 
27. vctrs:::validate_unique(names = names) 
28. vctrs:::stop_names_must_be_unique(which(duplicated(names))) 
29. vctrs:::stop_names(...) 
30. vctrs:::stop_vctrs(...)

And I checked traceback:

33.stop(fallback)
32.signal_abort(cnd)
31.abort(message, class = c(class, "vctrs_error"), ...)
30.stop_vctrs(message, class = c(class, "vctrs_error_names"), locations = locations, ...)
29.stop_names("Names must be unique.", class = "vctrs_error_names_must_be_unique", locations = locations)
28.stop_names_must_be_unique(which(duplicated(names)))
27.validate_unique(names = names)
26.vctrs::vec_as_names(names, repair = "check_unique")
25.withCallingHandlers(expr, simpleError = function(cnd) { abort(conditionMessage(cnd), parent = cnd) })
24.instrument_base_errors(expr)
23.doTryCatch(return(expr), name, parentenv, handler)
22.tryCatchOne(expr, names, parentenv, handlers[[1L]])
21.tryCatchList(expr, classes, parentenv, handlers)
20.tryCatch(instrument_base_errors(expr), vctrs_error_subscript = function(cnd) { cnd$subscript_action <- subscript_action(type) cnd$subscript_elt <- "column" cnd_signal(cnd) ...
19.with_subscript_errors(vctrs::vec_as_names(names, repair = "check_unique"))
18.rename_impl(NULL, .vars, quo(c(...)), strict = .strict)
17.tidyselect::vars_rename(names(.data), !!!enquos(...))
16.rename.data.frame(.data = ., variable = skim_variable)
15.dplyr::rename(.data = ., variable = skim_variable)
14.function_list[[k]](value)
13.withVisible(function_list[[k]](value))
12.freduce(value, `_function_list`)
11.`_fseq`(`_lhs`)
10.eval(quote(`_fseq`(`_lhs`)), env, env)
9.eval(quote(`_fseq`(`_lhs`)), env, env)
8.withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
7.dplyr::left_join(x = df_results %>% dplyr::group_modify(.f = ~tibble::as_tibble(skimr::skim(purrr::keep(.x = ., .p = ..f))), keep = FALSE) %>% dplyr::ungroup(x = .), y = dplyr::tally(df_results), by = purrr::map_chr(.x = grouping.vars, .f = rlang::as_string)) %>% dplyr::mutate(.data = ., n = n - n_missing) %>% purrr::set_names(x = ., ...
6.groupedstats::grouped_summary(data = data, grouping.vars = { { x } ...
5.eval(lhs, parent, parent)
4.eval(lhs, parent, parent)
3.groupedstats::grouped_summary(data = data, grouping.vars = { { x } ...
2.mean_labeller(data = data, x = { { x } ...
1.ggwithinstats(data = emotion_rating_dt_50, x = variable, y = Emotion_rating, point.path = FALSE, mean.path = FALSE, effsize.type = "partial_eta", p.adjust.method = "fdr", ggtheme = theme_classic(), palette = "Darjeeling2", package = "wesanderson", ggstatsplot.layer = FALSE, xlab = "Dilemma types"

What I have tried:

  1. I googled about this error. Did not get much helpful information.
  2. I updated r-base and all r packages. Not worked.
  3. I checked whether this problem was specific to ggwithinplot. And I found ggbetweenplot worked well even in the large sample (N=2000).
  4. I checked whether it was due to problems with the input data, which is required to be long-format. I did not find anything dubious.
  5. I checked whether the names of columns in the data frame duplicated. No. So I was really confused about the meaning of "name must be unique."

(https://stackoverflow.com/questions/60720673/how-to-solve-error-names-must-be-unique-in-r-package-ggstatsplot)

Here comes the reprex:

library("tidyverse")
library("ggstatsplot")
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4
library("bruceR")
#> 载入需要的程辑包:rio
#> 载入需要的程辑包:data.table
#> 
#> 载入程辑包:'data.table'
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
#> 载入需要的程辑包:psych
#> 
#> 载入程辑包:'psych'
#> The following objects are masked from 'package:ggplot2':
#> 
#>     %+%, alpha
#> 载入需要的程辑包:lubridate
#> 
#> 载入程辑包:'lubridate'
#> The following objects are masked from 'package:data.table':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following object is masked from 'package:base':
#> 
#>     date
#> 载入需要的程辑包:performance
#> Registered S3 methods overwritten by 'huge':
#>   method    from   
#>   plot.sim  BDgraph
#>   print.sim BDgraph
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
#> ========================================================
#> BRoadly Useful Collections and Extensions of R functions
#> ========================================================
#> Loaded packages:
#> <U+2714> bruceR (version 0.4.0)
#> <U+2714> rio, dplyr, data.table, psych, stringr, lubridate, performance, ggplot2
#> Update:
#> devtools::install_github("psychbruce/bruceR")
#> Citation:
#> Bao, H.-W.-S. (2020). bruceR: Broadly useful collections and extensions of R functions (version 0.4.0). Retrieved from https://github.com/psychbruce/bruceR
data <- import("E:/Zengxiaoyu/zxy_projcet/!ncov/data/Covid_Q1Q2data_minus200_0316.xlsx")
#> New names:
#> * hubei -> hubei...1396
data$hubei<-data$hubei...666
data$hubei <- as.factor(data$hubei)
#data frame
emotion_df <- data.frame(data$N1_disself,data$N1_disFAMI,data$N1_disHB,data$hubei)

emotion_df <- as.data.table(emotion_df)

#data preparation for repeated measure

long_emotion_rating_dt<-tidyr::pivot_longer(emotion_df, 1:3,names_to = 'variable', values_to = "Emotion_rating")

emotion_rating_dt_50<-subset(long_emotion_rating_dt,data.hubei=="HuBei")
# to plot
grid::grid.newpage()
ggwithinstats(
  data = emotion_rating_dt_50,
  x = variable, # > 2 groups
  y = Emotion_rating,
  point.path = FALSE,
  mean.path = FALSE,
  effsize.type = 'partial_eta' ,
  p.adjust.method = "fdr",
  ggtheme = theme_classic(),
  palette = "Darjeeling2",
  package = "wesanderson",
  ggstatsplot.layer = FALSE,
  xlab = "Dilemma types", 
  ylab = "Emotion rating(1=appealing,7=appaling)",
  title = "Emotion rating for fout types moral dilemmas"
)
#> Note: 95% CI for effect size estimate was computed with 100 bootstrap samples.
#> 
#> Error: Names must be unique.
Created on 2020-03-17 by the reprex package (v0.3.0)

data frame image

session info

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 15063)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

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

other attached packages:
 [1] sessioninfo_1.1.1  reprex_0.3.0       reshape_0.8.8      gginnards_0.0.3    VGAM_1.1-2         parameters_0.6.0  
 [7] nnet_7.3-13        openxlsx_4.1.4     summarytools_0.9.6 ggcorrplot_0.1.3   bruceR_0.4.0       performance_0.4.4 
[13] lubridate_1.7.4    psych_1.9.12.31    data.table_1.12.8  rio_0.5.16         ggstatsplot_0.3.1  forcats_0.5.0     
[19] stringr_1.4.0      dplyr_0.8.5        purrr_0.3.3        readr_1.3.1        tidyr_1.0.2        tibble_2.1.3      
[25] ggplot2_3.3.0      tidyverse_1.3.0    drawMap_0.1.0     

loaded via a namespace (and not attached):
  [1] estimability_1.3          GGally_1.4.0              lavaan_0.6-5              coda_0.19-3              
  [5] acepack_1.4.1             knitr_1.28                multcomp_1.4-12           rpart_4.1-15             
  [9] inline_0.3.15             generics_0.0.2            callr_3.4.2               cowplot_1.0.0            
 [13] TH.data_1.0-10            xml2_1.2.5                httpuv_1.5.2              StanHeaders_2.21.0-1     
 [17] assertthat_0.2.1          d3Network_0.5.2.1         WRS2_1.0-0                xfun_0.12                
 [21] hms_0.5.3                 evaluate_0.14             promises_1.1.0            fansi_0.4.1              
 [25] dbplyr_1.4.2              readxl_1.3.1              igraph_1.2.4.2            htmlwidgets_1.5.1        
 [29] DBI_1.1.0                 Rsolnp_1.16               ellipsis_0.3.0            paletteer_1.1.0          
 [33] rcompanion_2.3.25         backports_1.1.5           pbivnorm_0.6.0            insight_0.8.2            
 [37] rapportools_1.0           libcoin_1.0-5             jmvcore_1.2.5             vctrs_0.2.4              
 [41] sjlabelled_1.1.3          abind_1.4-5               withr_2.1.2               pryr_0.1.4               
 [45] metaBMA_0.6.2             checkmate_2.0.0           bdsmatrix_1.3-4           emmeans_1.4.5            
 [49] fdrtool_1.2.15            prettyunits_1.1.1         fastGHQuad_1.0            mnormt_1.5-6             
 [53] cluster_2.1.0             mi_1.0                    crayon_1.3.4              pkgconfig_2.0.3          
 [57] nlme_3.1-145              statsExpressions_0.3.1    palr_0.2.0                pals_1.6                 
 [61] rlang_0.4.5               lifecycle_0.2.0           miniUI_0.1.1.1            groupedstats_0.2.0       
 [65] skimr_2.1                 LaplacesDemon_16.1.4      MatrixModels_0.4-1        sandwich_2.5-1           
 [69] kutils_1.69               EMT_1.1                   modelr_0.1.6              dichromat_2.0-0          
 [73] tcltk_3.6.3               cellranger_1.1.0          matrixStats_0.56.0        broomExtra_2.5.0         
 [77] lmtest_0.9-37             Matrix_1.2-18             regsem_1.5.2              loo_2.2.0                
 [81] mc2d_0.1-18               carData_3.0-3             boot_1.3-24               zoo_1.8-7                
 [85] base64enc_0.1-3           whisker_0.4               processx_3.4.2            png_0.1-7                
 [89] viridisLite_0.3.0         rjson_0.2.20              oompaBase_3.2.9           pander_0.6.3             
 [93] ggExtra_0.9               afex_0.26-0               multcompView_0.1-8        coin_1.3-1               
 [97] arm_1.10-1                jpeg_0.1-8.1              rockchalk_1.8.144         ggsignif_0.6.0           
[101] scales_1.1.0              magrittr_1.5              plyr_1.8.6                compiler_3.6.3           
[105] rstantools_2.0.0          bbmle_1.0.23.1            RColorBrewer_1.1-2        lme4_1.1-21              
[109] cli_2.0.2                 lmerTest_3.1-1            pbapply_1.4-2             ps_1.3.2                 
[113] TMB_1.7.16                Brobdingnag_1.2-6         htmlTable_1.13.3          Formula_1.2-3            
[117] MASS_7.3-51.5             mgcv_1.8-31               tidyselect_1.0.0          stringi_1.4.6            
[121] lisrelToR_0.1.4           sem_3.1-9                 jtools_2.0.2              OpenMx_2.17.3            
[125] latticeExtra_0.6-29       ggrepel_0.8.2             bridgesampling_1.0-0      grid_3.6.3               
[129] tools_3.6.3               parallel_3.6.3            matrixcalc_1.0-3          rstudioapi_0.11          
[133] foreign_0.8-76            gridExtra_2.3             ipmisc_1.2.0              pairwiseComparisons_0.2.5
[137] BDgraph_2.62              digest_0.6.25             shiny_1.4.0.2             nortest_1.0-4            
[141] jmv_1.2.5                 Rcpp_1.0.3                car_3.0-7                 broom_0.5.5              
[145] metafor_2.1-0             ez_4.4-0                  BayesFactor_0.9.12-4.2    metaplus_0.7-11          
[149] later_1.0.0               httr_1.4.1                effectsize_0.2.0          sjstats_0.17.9           
[153] colorspace_1.4-1          rvest_0.3.5               XML_3.99-0.3              fs_1.3.2                 
[157] truncnorm_1.0-8           rematch2_2.1.0            expm_0.999-4              mapproj_1.2.7            
[161] jcolors_0.0.4             MuMIn_1.43.15             xtable_1.8-4              jsonlite_1.6.1           
[165] nloptr_1.2.2.1            corpcor_1.6.9             rstan_2.19.3              glasso_1.11              
[169] zeallot_0.1.0             modeltools_0.2-23         scico_1.1.0               R6_2.4.1                 
[173] Hmisc_4.3-1               broom.mixed_0.2.4         pillar_1.4.3              htmltools_0.4.0          
[177] mime_0.9                  glue_1.3.2                fastmap_1.0.1             minqa_1.2.4              
[181] codetools_0.2-16          maps_3.3.0                pkgbuild_1.0.6            mvtnorm_1.1-0            
[185] lattice_0.20-40           numDeriv_2016.8-1.1       huge_1.3.4                curl_4.3                 
[189] DescTools_0.99.34         gtools_3.8.1              clipr_0.7.0               magick_2.3               
[193] logspline_2.1.15          zip_2.0.4                 survival_3.1-11           rmarkdown_2.1            
[197] qgraph_1.6.5              repr_1.1.0                munsell_0.5.0             semPlot_1.1.2            
[201] sjmisc_2.8.3              haven_2.2.0               reshape2_1.4.3            gtable_0.3.0             
[205] bayestestR_0.5.2  

Any ideas?

IndrajeetPatil commented 4 years ago

Can you please post output from sessioninfo::sessioninfo()?

XiaoyuZeng commented 4 years ago

Can you please post output from sessioninfo::sessioninfo()?

Updated. Sorry.

IndrajeetPatil commented 4 years ago

Hmm, strange. I can't seem to find anything amiss about the package versions. They seem to be the same ones I have on my local machine and I don't get any error for the function where you get the error. In your traceback, you can see that the function mean_labeller is where the execution runs into problems.

But it runs just fine, not only on my local machine but also on virtual Travis and AppVeyor machines for both R 3.6 and R 4.0.

library(ggstatsplot)
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4

ggstatsplot:::mean_labeller(data = mtcars, am, wt)
#> # A tibble: 2 x 4
#>   am       wt label                               n_label      
#>   <fct> <dbl> <chr>                               <chr>        
#> 1 0      3.77 list(~italic(widehat(mu))== 3.769 ) "0\n(n = 19)"
#> 2 1      2.41 list(~italic(widehat(mu))== 2.411 ) "1\n(n = 13)"

Created on 2020-03-17 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R Under development (unstable) (2020-02-28 r77874) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> ctype English_United States.1252 #> tz Europe/Berlin #> date 2020-03-17 #> #> - Packages ------------------------------------------------------------------- #> ! package * version date lib #> abind 1.4-5 2016-07-21 [1] #> assertthat 0.2.1 2019-03-21 [1] #> backports 1.1.5 2019-10-02 [1] #> base64enc 0.1-3 2015-07-28 [1] #> BayesFactor 0.9.12-4.2 2018-05-19 [1] #> bayestestR 0.5.2.1 2020-03-16 [1] #> bbmle 1.0.23.1 2020-02-03 [1] #> bdsmatrix 1.3-4 2020-01-13 [1] #> boot 1.3-24 2019-12-20 [2] #> bridgesampling 1.0-0 2020-02-26 [1] #> Brobdingnag 1.2-6 2018-08-13 [1] #> broom 0.5.3.9000 2020-03-01 [1] #> broom.mixed 0.2.4.9000 2020-03-09 [1] #> broomExtra 2.0.0.9000 2020-03-11 [1] #> callr 3.4.2 2020-02-12 [1] #> car 3.0-7 2020-03-11 [1] #> carData 3.0-3 2019-11-16 [1] #> cellranger 1.1.0 2016-07-27 [1] #> cli 2.0.2 2020-02-28 [1] #> cluster 2.1.0 2019-06-19 [2] #> coda 0.19-3 2019-07-05 [1] #> codetools 0.2-16 2018-12-24 [2] #> coin 1.3-1 2019-08-28 [1] #> colorspace 1.4-1 2019-03-18 [1] #> cowplot 1.0.0 2019-07-11 [1] #> crayon 1.3.4 2017-09-16 [1] #> curl 4.3 2019-12-02 [1] #> data.table 1.12.8 2019-12-09 [1] #> desc 1.2.0 2018-05-01 [1] #> DescTools 0.99.34 2020-03-12 [1] #> devtools 2.2.2 2020-02-17 [1] #> dichromat 2.0-0 2013-01-24 [1] #> digest 0.6.25 2020-02-23 [1] #> dplyr 0.8.5 2020-03-07 [1] #> effectsize 0.2.0.1 2020-03-06 [1] #> ellipsis 0.3.0 2019-09-20 [1] #> emmeans 1.4.5 2020-03-04 [1] #> EMT 1.1 2013-01-29 [1] #> estimability 1.3 2018-02-11 [1] #> evaluate 0.14 2019-05-28 [1] #> expm 0.999-4 2019-03-21 [1] #> ez 4.4-0 2016-11-02 [1] #> fansi 0.4.1 2020-01-08 [1] #> fastGHQuad 1.0 2018-09-30 [1] #> fastmap 1.0.1 2019-10-08 [1] #> forcats 0.5.0 2020-03-01 [1] #> foreign 0.8-75 2020-01-20 [2] #> fs 1.3.2 2020-03-05 [1] #> generics 0.0.2 2018-11-29 [1] #> ggcorrplot 0.1.3 2019-05-19 [1] #> ggExtra 0.9 2019-08-27 [1] #> ggplot2 3.3.0 2020-03-05 [1] #> ggrepel 0.8.2 2020-03-08 [1] #> ggsignif 0.6.0 2019-08-08 [1] #> ggstatsplot * 0.3.1.9000 2020-03-11 [1] #> glue 1.3.2 2020-03-12 [1] #> gridExtra 2.3 2017-09-09 [1] #> groupedstats 0.2.0 2020-02-28 [1] #> gtable 0.3.0 2019-03-25 [1] #> gtools 3.8.1 2018-06-26 [1] #> haven 2.2.0 2019-11-08 [1] #> highr 0.8 2019-03-20 [1] #> hms 0.5.3 2020-01-08 [1] #> htmltools 0.4.0 2019-10-04 [1] #> httpuv 1.5.2 2019-09-11 [1] #> inline 0.3.15 2018-05-18 [1] #> insight 0.8.2.1 2020-03-16 [1] #> ipmisc 1.2.0.9000 2020-03-05 [1] #> jcolors 0.0.4 2019-05-22 [1] #> jmv 1.2.5 2020-02-17 [1] #> jmvcore 1.2.5 2020-02-05 [1] #> jsonlite 1.6.1 2020-02-02 [1] #> knitr 1.28 2020-02-06 [1] #> LaplacesDemon 16.1.4 2020-02-06 [1] #> later 1.0.0 2019-10-04 [1] #> lattice 0.20-40 2020-02-19 [2] #> libcoin 1.0-5 2019-08-27 [1] #> lifecycle 0.2.0.9000 2020-03-16 [1] #> lme4 1.1-21 2019-03-05 [1] #> lmtest 0.9-37 2019-04-30 [1] #> logspline 2.1.15 2019-11-08 [1] #> loo 2.2.0 2019-12-19 [1] #> magrittr 1.5 2014-11-22 [1] #> mapproj 1.2.7 2020-02-03 [1] #> maps 3.3.0 2018-04-03 [1] #> MASS 7.3-51.5 2019-12-20 [2] #> Matrix 1.2-18 2019-11-27 [2] #> MatrixModels 0.4-1 2015-08-22 [1] #> matrixStats 0.56.0 2020-03-13 [1] #> mc2d 0.1-18 2017-03-06 [1] #> memoise 1.1.0 2017-04-21 [1] #> metaBMA 0.6.2 2019-09-16 [1] #> metafor 2.1-0 2019-05-14 [1] #> metaplus 0.7-11 2018-04-01 [1] #> mgcv 1.8-31 2019-11-09 [2] #> mime 0.9 2020-02-04 [1] #> miniUI 0.1.1.1 2018-05-18 [1] #> minqa 1.2.4 2014-10-09 [1] #> mnormt 1.5-6 2020-02-03 [1] #> modelr 0.1.6 2020-02-22 [1] #> modeltools 0.2-23 2020-03-05 [1] #> multcomp 1.4-12 2020-01-10 [1] #> multcompView 0.1-8 2019-12-19 [1] #> munsell 0.5.0 2018-06-12 [1] #> mvtnorm 1.1-0 2020-02-24 [1] #> nlme 3.1-144 2020-02-06 [2] #> nloptr 1.2.2.1 2020-03-11 [1] #> nortest 1.0-4 2015-07-30 [1] #> numDeriv 2016.8-1.1 2019-06-06 [1] #> oompaBase 3.2.9 2019-08-24 [1] #> openxlsx 4.1.4 2019-12-06 [1] #> pairwiseComparisons 0.2.5 2020-02-11 [1] #> paletteer 1.1.0 2020-03-10 [1] #> palr 0.2.0 2020-01-30 [1] #> pals 1.6 2019-12-04 [1] #> parameters 0.6.0 2020-03-12 [1] #> pbapply 1.4-2 2019-08-31 [1] #> performance 0.4.4.1 2020-03-11 [1] #> pillar 1.4.3 2019-12-20 [1] #> pkgbuild 1.0.6 2019-10-09 [1] #> pkgconfig 2.0.3 2019-09-22 [1] #> pkgload 1.0.2 2018-10-29 [1] #> plyr 1.8.6 2020-03-03 [1] #> prettyunits 1.1.1 2020-01-24 [1] #> processx 3.4.2 2020-02-09 [1] #> promises 1.1.0 2019-10-04 [1] #> ps 1.3.2 2020-02-13 [1] #> psych 1.9.12.31 2020-01-08 [1] #> purrr 0.3.3 2019-10-18 [1] #> R6 2.4.1 2019-11-12 [1] #> rcompanion 2.3.25 2020-02-09 [1] #> Rcpp 1.0.4 2020-03-17 [1] #> readxl 1.3.1 2019-03-13 [1] #> rematch2 2.1.0 2019-07-11 [1] #> remotes 2.1.1 2020-02-15 [1] #> repr 1.1.0 2020-01-28 [1] #> reshape 0.8.8 2018-10-23 [1] #> reshape2 1.4.3 2017-12-11 [1] #> rio 0.5.16 2018-11-26 [1] #> rjson 0.2.20 2018-06-08 [1] #> rlang 0.4.5 2020-03-01 [1] #> rmarkdown 2.1 2020-01-20 [1] #> rprojroot 1.3-2 2018-01-03 [1] #> rstan 2.19.3 2020-02-11 [1] #> rstantools 2.0.0 2019-09-15 [1] #> rstudioapi 0.11 2020-02-07 [1] #> sandwich 2.5-1 2019-04-06 [1] #> scales 1.1.0 2019-11-18 [1] #> scico 1.1.0 2018-11-20 [1] #> sessioninfo 1.1.1 2018-11-05 [1] #> shiny 1.4.0.2 2020-03-13 [1] #> sjlabelled 1.1.3 2020-01-28 [1] #> sjmisc 2.8.3 2020-01-10 [1] #> sjstats 0.17.9 2020-02-06 [1] #> skimr 2.1 2020-02-01 [1] #> StanHeaders 2.21.0-1 2020-01-19 [1] #> statsExpressions 0.3.1 2020-02-14 [1] #> stringi 1.4.6 2020-02-17 [1] #> stringr 1.4.0 2019-02-10 [1] #> survival 3.1-8 2019-12-03 [2] #> testthat 2.3.2 2020-03-02 [1] #> TH.data 1.0-10 2019-01-21 [1] #> tibble 2.1.3 2019-06-06 [1] #> tidyr 1.0.2 2020-01-24 [1] #> tidyselect 1.0.0 2020-01-27 [1] #> D TMB 1.7.16 2020-01-15 [1] #> usethis 1.5.1.9000 2020-03-16 [1] #> utf8 1.1.4 2018-05-24 [1] #> vctrs 0.2.4 2020-03-10 [1] #> viridisLite 0.3.0 2018-02-01 [1] #> withr 2.1.2 2018-03-15 [1] #> WRS2 1.0-0 2019-06-06 [1] #> xfun 0.12 2020-01-13 [1] #> xtable 1.8-4 2019-04-21 [1] #> yaml 2.2.1 2020-02-01 [1] #> zeallot 0.1.0 2018-01-28 [1] #> zip 2.0.4 2019-09-01 [1] #> zoo 1.8-7 2020-01-10 [1] #> source #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (easystats/bayestestR@6ee7e37) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (tidymodels/broom@3c922d5) #> Github (bbolker/broom.mixed@c2587ef) #> Github (IndrajeetPatil/broomExtra@d28ba11) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (easystats/effectsize@64bfbc3) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> local #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (easystats/insight@e0b229b) #> local #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (r-lib/lifecycle@355dcba) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (easystats/performance@913fee0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> Github (r-lib/usethis@3e7c8b2) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> CRAN (R 4.0.0) #> #> [1] C:/Users/inp099/Documents/R/win-library/4.0 #> [2] C:/Program Files/R/R-devel/library #> #> D -- DLL MD5 mismatch, broken installation. ```

What do you get if you run the following?

ggstatsplot:::mean_labeller(data = mtcars, am, wt)
XiaoyuZeng commented 4 years ago

Hmm, strange. I can't seem to find anything amiss about the package versions. They seem to be the same ones I have on my local machine and I don't get any error for the function where you get the error. In your traceback, you can see that the function mean_labeller is where the execution runs into problems.

But it runs just fine, not only on my local machine but also on virtual Travis and AppVeyor machines for both R 3.6 and R 4.0.

library(ggstatsplot)
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4

ggstatsplot:::mean_labeller(data = mtcars, am, wt)
#> # A tibble: 2 x 4
#>   am       wt label                               n_label      
#>   <fct> <dbl> <chr>                               <chr>        
#> 1 0      3.77 list(~italic(widehat(mu))== 3.769 ) "0\n(n = 19)"
#> 2 1      2.41 list(~italic(widehat(mu))== 2.411 ) "1\n(n = 13)"

Created on 2020-03-17 by the reprex package (v0.3.0)

Session info What do you get if you run the following?

ggstatsplot:::mean_labeller(data = mtcars, am, wt)

It runs just fine.

ggstatsplot:::mean_labeller(data = mtcars, am, wt)
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4
#> # A tibble: 2 x 4
#>   am       wt label                               n_label      
#>   <fct> <dbl> <chr>                               <chr>        
#> 1 0      3.77 list(~italic(widehat(mu))== 3.769 ) "0\n(n = 19)"
#> 2 1      2.41 list(~italic(widehat(mu))== 2.411 ) "1\n(n = 13)"
Created on 2020-03-17 by the reprex package (v0.3.0)
IndrajeetPatil commented 4 years ago

So this seems to have something to do with your data and I can't diagnose that without a self-contained reprex.

Your original reprex points to data on your local machine: data <- import("E:/Zengxiaoyu/zxy_projcet/!ncov/data/Covid_Q1Q2data_minus200_0316.xlsx")

XiaoyuZeng commented 4 years ago

Thanks, Indrajeet. Thanks for the feedback. And thank you for guiding me to make the problem clearer.

I made another reprex with minimal data. Error remains.


library("tidyverse")
library("ggstatsplot")
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4
df <- read.table(
  header = TRUE,
  text = "  hubei self other province
1 HuBei    7    10        5
2 HuBei    2     0        0
3 HuBei    0     0      -22
4 HuBei    2     2        9
5 HuBei   11    -1       -4
6 HuBei    0     0        3
"
)

long_df <- tidyr::pivot_longer(df, 2:4, names_to = "variable", values_to = "Emotion_rating")
ggwithinstats(
  data = long_df,
  x = variable, # > 2 groups
  y = Emotion_rating,
  point.path = FALSE
)
#> Note: 95% CI for effect size estimate was computed with 100 bootstrap samples.
#> 
#> Error: Names must be unique.
Created on 2020-03-18 by the reprex package (v0.3.0)
IndrajeetPatil commented 4 years ago

Thanks a lot! I can reproduce this. This actually seems to trace to groupedstats package, so I will move the issue there: https://github.com/IndrajeetPatil/groupedstats/issues/24