kassambara / rstatix

Pipe-friendly Framework for Basic Statistical Tests in R
https://rpkgs.datanovia.com/rstatix/
440 stars 50 forks source link

games_howell_test under rstatix in R is not working #183

Open kyermekb opened 1 year ago

kyermekb commented 1 year ago

I raised this question in https://stackoverflow.com/questions/75546541/problems-with-games-howell-test-in-r-or-df-must-be-size-15-or-1-not-12. People suggested it could be a bug. Please could you look at it. Thanks.

The link is also copied below: https://stackoverflow.com/questions/75546541/problems-with-games-howell-test-in-r-or-df-must-be-size-15-or-1-not-12

GegznaV commented 1 year ago

Reprex:

library(rstatix)
#> 
#> Attaching package: 'rstatix'
#> The following object is masked from 'package:stats':
#> 
#>     filter

df <- structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 
  2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 
  6L, 6L), levels = c("Geno1", "Geno2", "Geno3", "Geno4", "Geno5", 
    "Geno6"), class = "factor"), Tillering = c(22L, 23L, 23L, 23L, 
      22L, 22L, 22L, 22L, 23L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 21L, 
      21L, 20L, 21L, 22L, 22L, 22L, 22L)), row.names = c(NA, -24L),
  class = "data.frame")

games_howell_test(df, Tillering~Genotype, detailed = TRUE)
#> Error in `mutate()`:
#> ℹ In argument: `data = map(.data$data, .f, ...)`.
#> Caused by error in `map()`:
#> ℹ In index: 1.
#> Caused by error in `mutate()`:
#> ℹ In argument: `df = df$value`.
#> Caused by error:
#> ! `df` must be size 15 or 1, not 12.
#> Backtrace:
#>      ▆
#>   1. ├─rstatix::games_howell_test(df, Tillering ~ Genotype, detailed = TRUE)
#>   2. │ └─data %>% doo(.games_howell_test, formula, conf.level = conf.level)
#>   3. ├─rstatix::doo(., .games_howell_test, formula, conf.level = conf.level)
#>   4. │ └─... %>% mutate(data = map(.data$data, .f, ...))
#>   5. ├─dplyr::mutate(., data = map(.data$data, .f, ...))
#>   6. ├─dplyr:::mutate.data.frame(., data = map(.data$data, .f, ...))
#>   7. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
#>   8. │   ├─base::withCallingHandlers(...)
#>   9. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
#>  10. │     └─mask$eval_all_mutate(quo)
#>  11. │       └─dplyr (local) eval()
#>  12. ├─purrr::map(.data$data, .f, ...)
#>  13. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#>  14. │   ├─purrr:::with_indexed_errors(...)
#>  15. │   │ └─base::withCallingHandlers(...)
#>  16. │   ├─purrr:::call_with_cleanup(...)
#>  17. │   └─rstatix (local) .f(.x[[i]], ...)
#>  18. │     └─... %>% mutate(method = "Games-Howell")
#>  19. ├─dplyr::mutate(., method = "Games-Howell")
#>  20. ├─rstatix::add_significance(., "p.adj")
#>  21. │ └─rstatix:::get_test_attributes(data)
#>  22. ├─tibble::add_column(., .y. = outcome, .before = "group1")
#>  23. │ └─base::is.data.frame(.data)
#>  24. ├─tibble::add_column(., n1 = n1, n2 = n2, .after = "group2")
#>  25. │ └─base::is.data.frame(.data)
#>  26. ├─dplyr::mutate(...)
#>  27. ├─dplyr:::mutate.data.frame(...)
#>  28. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
#>  29. │   ├─base::withCallingHandlers(...)
#>  30. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
#>  31. │     └─mask$eval_all_mutate(quo)
#>  32. │       └─dplyr (local) eval()
#>  33. ├─dplyr:::dplyr_internal_error(...)
#>  34. │ └─rlang::abort(class = c(class, "dplyr:::internal_error"), dplyr_error_data = data)
#>  35. │   └─rlang:::signal_abort(cnd, .file)
#>  36. │     └─base::signalCondition(cnd)
#>  37. └─dplyr (local) `<fn>`(`<dpl:::__>`)
#>  38.   └─rlang::abort(message, class = error_class, parent = parent, call = error_call)

Created on 2023-05-15 with reprex v2.0.2

Might this be related to the fact that some groups have zero variance?