Skip to content

Commit cf9d9f1

Browse files
kei51eclaude
andcommitted
feat(one-sample-t-test): add Diff Conf Low/High columns to tidy model output
Add confidence interval for the difference (mean - mu) to the type="model" output as "Diff Conf Low" and "Diff Conf High", complementing the existing "Difference" column. Callers no longer need to subtract mu themselves. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1fffd8c commit cf9d9f1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

R/test_wrapper.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,6 +3619,8 @@ tidy.one_sample_t_test_exploratory <- function(x, type = "model", conf_level = 0
36193619
`P Value` = x$htest$p.value,
36203620
`Conf Low` = x$htest$conf.int[1],
36213621
`Conf High` = x$htest$conf.int[2],
3622+
`Diff Conf Low` = x$htest$conf.int[1] - x$mu,
3623+
`Diff Conf High` = x$htest$conf.int[2] - x$mu,
36223624
`Cohen's d` = x$cohens_d,
36233625
`Power` = x$power,
36243626
`Test Direction` = direction,

tests/testthat/test_one_sample_t_test.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ test_that("tidy model type returns the expected column set", {
211211
expected_cols <- c(
212212
"Number of Rows", "Mean", "Std Deviation", "Std Error",
213213
"Hypothesized Mean", "Difference", "t Value", "DF", "P Value",
214-
"Conf Low", "Conf High", "Cohen's d", "Power",
215-
"Test Direction", "Result"
214+
"Conf Low", "Conf High", "Diff Conf Low", "Diff Conf High",
215+
"Cohen's d", "Power", "Test Direction", "Result"
216216
)
217217
for (col in expected_cols) {
218218
expect_true(col %in% names(tidied), info = paste("Missing column:", col))
@@ -237,6 +237,8 @@ test_that("tidy model values are numerically correct", {
237237
expect_equal(tidied$`P Value`, expected$p.value)
238238
expect_equal(tidied$`Conf Low`, expected$conf.int[1])
239239
expect_equal(tidied$`Conf High`, expected$conf.int[2])
240+
expect_equal(tidied$`Diff Conf Low`, expected$conf.int[1] - 4.5)
241+
expect_equal(tidied$`Diff Conf High`, expected$conf.int[2] - 4.5)
240242
})
241243

242244
test_that("tidy model Test Direction maps correctly from alternative", {

0 commit comments

Comments
 (0)