3

When I run the t-test for a numeric and a dichotomous variable there in no problem and I can see the results. The problem is when I run the ggttest of the same t-test. There is an error and says that one of my variable is not found. I do not why that happens. The aml dataset I used is from package boot. Below you can see the code:

https://i.stack.imgur.com/7kuaA.png

library(gginference)
time_group.test16537 = t.test(formula = time~group,
                              data = aml,
                              alternative = "two.sided",
                              paired = FALSE,
                              var.equal = FALSE,
                              conf.level = 0.95)
    time_group.test16537


    ggttest(time_group.test16537,
            colaccept="lightsteelblue1", 
            colreject="gray84", 
            colstat="navyblue")
Katerina
  • 33
  • 6
  • 1
    Hi @Katerina, it's a good question. I can see you use aml from package boot. Unfortunately people cannot reproduce your error with an image. Do you mind writing the two lines of code as part of your question, and also the libraries used? – StupidWolf Apr 04 '20 at 21:13
  • @StupidWolf thank you very much for your comment. I am new to this forum, so I do not know very well how to write down correctly the questions. – Katerina Apr 04 '20 at 22:16
  • Cool @Katerina, yeah see the answer below. It's some weird bug in the package.. The fix below should give you the plot – StupidWolf Apr 04 '20 at 22:19
  • 1
    @StupidWolf everything worked out well. Thank you. – Katerina Apr 04 '20 at 22:39

2 Answers2

2

The problem comes with these lines of code in ggttest:

datnames <- strsplit(t$data.name, splitter)
len1 <- length(eval(parse(text = datnames[[1]][1])))
len2 <- length(eval(parse(text = datnames[[1]][2])))

It tries to find the len of group and time, but it doesn't see that it came from a data.frame. Pretty bad bug...

For your situation, supposedly you have less than 30 in each group and it plots a t-distribution, so do:

library(gginference)
library(boot)
gginference:::normt(t.test(time~group,data=aml),
colaccept = "lightsteelblue1",colreject = "grey84", 
colstat = "navyblue")

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
0

t.test doesn't store your data in the output so there is no way that you could extract the data from the list of the output of t.test.

The only way to use formula is:

library(gginference)
t_test <- t.test(questionnaire$pulse ~ questionnaire$gender)
ggttest(t_test)

Original answer here: How to extract the dataset from an "htest" object when using formula in r

akis
  • 154
  • 1
  • 8