I have a simple question. I'd like like to use the group.test argument to conduct a t.test instead of an f.test between the two groups. I see from the help documents that this should be related to the independence.test function but I am not quite exactly sure what to do.
vtable::sumtable(data = mtcars,
vars = "mpg",
group = "am",
out = "return",
group.test = T)
#> Variable N Mean SD N Mean SD Test
#> 1 am 0 1
#> 2 mpg 19 17 3.8 13 24 6.2 F=16.86***
Created on 2023-08-24 with reprex v2.0.2
Apologies for the slow reply; been a moment since I searched vtable.
As per the docs, as you noticed, doing a custom
group.testrequires that you write a function suitable to be passed toindependence.test. This means that it returns a list with (1) the name of the test statistic, (2) the statistic, and (3) the p-value. So to do a t-test you'll have to write a function that does that, and then pass it togroup.testas an option fornumeric.test(or similarly if you want to write a function forfactor.test)Edit: in vtable version 1.4.5, which is now on CRAN, this is included in the package, and you can get it using
group.test = list('numeric.test' = vtable:::groupt.it)