Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: BUG in R-devel for paired/unpaired tests #169

Closed
3 tasks done
joanbirules opened this issue Jun 18, 2024 · 4 comments
Closed
3 tasks done

[Bug]: BUG in R-devel for paired/unpaired tests #169

joanbirules opened this issue Jun 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@joanbirules
Copy link

joanbirules commented Jun 18, 2024

What happened?

In this threat, @ddsjoberg commented on a bug with the paired/unpaired tests, giving an error when paired =F or T is entered into the t.test function:

#56 (comment)

I encounter the same error, when data are in wide format, the t.test works,
but when we put data in vertical format, then the t.test gives an error, as the example below:

x1 <- c(4.71, 6.66, 5.01, 4.6, 3.98)
x2 <- c(5.42, 7.1, 5.52, 6.05, 6.23)
t.test(x1, x2, paired=TRUE)
#> 
#>  Paired t-test
#> 
#> data:  x1 and x2
#> t = -3.1096, df = 4, p-value = 0.03589
#> alternative hypothesis: true mean difference is not equal to 0
#> 95 percent confidence interval:
#>  -2.029145 -0.114855
#> sample estimates:
#> mean difference 
#>          -1.072
data <- data.frame(
  group = rep(c("x1", "x2"), each = length(x1)),
  values = c(x1, x2)
)

t.test(values~group, data=data, paired=TRUE)
#> Error in t.test.formula(values ~ group, data = data, paired = TRUE): cannot use 'paired' in formula method

Created on 2024-06-18 with reprex v2.1.0

@ddsjoberg mentioned that this could be solved with ... |> utils::modifyList(list(paired = NULL), keep.null = FALSE)

but this gives me an error; as copied below:

utils::modifyList(list(paired = NULL), keep.null = FALSE)
#> Error in utils::modifyList(list(paired = NULL), keep.null = FALSE): argument "val" is missing, with no default

Created on 2024-06-18 with reprex v2.1.0
I would appreciate if someone could help me solve this problem, which appeared I believe with some updating of packages (the t.test function with paired data worked before normally)

thank you very much,
Joan

sessionInfo()

R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.4.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

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

time zone: Europe/Paris
tzcode source: internal

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

other attached packages:
 [1] readxl_1.4.3      data.table_1.15.4 ggpubr_0.6.0      Hmisc_5.1-3       corrplot_0.92    
 [6] lmerTest_3.1-3    lme4_1.1-35.3     Matrix_1.7-0      ez_4.4-0          png_0.1-8        
[11] ggbeeswarm_0.7.2  apa_0.3.4         lubridate_1.9.3   forcats_1.0.0     stringr_1.5.1    
[16] dplyr_1.1.4       purrr_1.0.2       readr_2.1.5       tidyr_1.3.1       tibble_3.2.1     
[21] ggplot2_3.5.1     tidyverse_2.0.0  

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1    farver_2.1.2        vipor_0.4.7         fastmap_1.2.0      
 [5] TH.data_1.1-2       rpart_4.1.23        digest_0.6.35       timechange_0.3.0   
 [9] estimability_1.5.1  lifecycle_1.0.4     cluster_2.1.6       survival_3.7-0     
[13] magrittr_2.0.3      compiler_4.4.0      rlang_1.1.4         tools_4.4.0        
[17] utf8_1.2.4          yaml_2.3.8          ggsignif_0.6.4      knitr_1.47         
[21] labeling_0.4.3      htmlwidgets_1.6.4   lsmeans_2.30-0      plyr_1.8.9         
[25] multcomp_1.4-25     abind_1.4-5         foreign_0.8-86      withr_3.0.0        
[29] numDeriv_2016.8-1.1 nnet_7.3-19         fansi_1.0.6         colorspace_2.1-0   
[33] emmeans_1.10.2      scales_1.3.0        MASS_7.3-60.2       cli_3.6.2          
[37] mvtnorm_1.2-5       crayon_1.5.2        ppcor_1.1           rmarkdown_2.27     
[41] generics_0.1.3      rstudioapi_0.16.0   reshape2_1.4.4      tzdb_0.4.0         
[45] minqa_1.2.7         splines_4.4.0       cellranger_1.1.0    base64enc_0.1-3    
[49] MBESS_4.9.3         vctrs_0.6.5         boot_1.3-30         sandwich_3.1-0     
[53] carData_3.0-5       car_3.1-2           hms_1.1.3           rstatix_0.7.2      
[57] htmlTable_2.4.2     Formula_1.2-5       beeswarm_0.4.0      glue_1.7.0         
[61] nloptr_2.0.3        codetools_0.2-20    stringi_1.8.4       gtable_0.3.5       
[65] munsell_0.5.1       pillar_1.9.0        htmltools_0.5.8.1   R6_2.5.1           
[69] evaluate_0.23       lattice_0.22-6      backports_1.5.0     broom_1.0.6        
[73] Rcpp_1.0.12         checkmate_2.3.1     gridExtra_2.3       coda_0.19-4.1      
[77] nlme_3.1-165        mgcv_1.9-1          xfun_0.44           zoo_1.8-12         
[81] pkgconfig_2.0.3

Relevant log output

Error in t.test.formula(values ~ group, data = data, paired = TRUE) : 
  cannot use 'paired' in formula method
 
Error in utils::modifyList(list(paired = NULL), keep.null = FALSE) : 
  argument "val" is missing, with no default

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@joanbirules joanbirules added the bug Something isn't working label Jun 18, 2024
@ddsjoberg
Copy link
Collaborator

@joanbirules thanks for the post. Can you update your post to include the call to the cardx t.test function. Also, can you please use the reprex package to create your reproducible example. This ensures the isolation of your environment when illustrating the issue.

@joanbirules
Copy link
Author

@ddsjoberg I have used the reprex to report the code parts, but I do not know what you mean by including the cardx t.test function, the function is already there isn't it?

@ddsjoberg
Copy link
Collaborator

This is the GitHub repo for the {cardx} R package. I don't think you're using that package, right? The best place to ask for help would be stackoverflow for a generic R function

@joanbirules
Copy link
Author

Ok thanks, I've done that.

May I ask, then this solution you proposed was specific to this cardx package?
utils::modifyList(list(paired = NULL), keep.null = FALSE)

It's quite strange that it gave you the same error but based on a different package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants