Home > Enterprise >  Is there a way to conduct one tailed t-test using add_p or add_difference function in tbl_summary?
Is there a way to conduct one tailed t-test using add_p or add_difference function in tbl_summary?

Time:10-11

I wanted to include the results of one-tailed t-test using gt_summary. Is there a way to do this?

CodePudding user response:

You can pass arguments to t.test() via the add_p(test.args=) argument. In your case, you'll want to pass the t.test(alternative = "less") (or "greater") argument. Example below!

library(gtsummary)

tbl <-
  trial %>%
  select(age, marker, trt) %>%
  tbl_summary(by = trt, missing = "no") %>%
  add_p(
    all_continuous() ~ "t.test",
    test.args = all_tests("t.test") ~ list(alternative = "less")
  )

enter image description here Created on 2021-10-10 by the reprex package (v2.0.1)

  • Related