Did behavior of "paired" argument in t.test() change?

Robert Baer via R-help <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <[email protected]>
Hi all,

Did the behavior of base t.test() subtly change with respect to the 
paired argument?

I think this code used to work with long form data, but now it seems not 
to  work:

     # Example long format data
     data_long <- data.frame(
       value = c(10, 12, 15, 8, 9, 11),
       time = factor(rep(c("before", "after"), each = 3))
     )

     t.test(value ~ time, data = data_long, paired = TRUE)

# Errorin t.test.formula(value ~ time, data = data_long, paired = TRUE) 
: # cannot use 'paired' in formula method

A quick Google seems to suggest that the above code should still work. 
What am I missing?

-------------------------------

Less sure about this one ...

Also, I thought it had always been possible to use x = "difference 
scores" in t.test(..., paired = TRUE) as long as y = NULL. My memory 
about this is less secure than the behavior above.

Control = c(10, 12, 15) Treat = c(8, 9, 11) data_wide <- data.frame( 
Control, Treat, Diff = Treat - Control) t.test(data_wide$Diff, NULL, 
"two.sided", 0, paired = FALSE) # works but y = NULL, mu = 0 mostly 
implies difference scores

t.test(data_wide$Diff, NULL, "two.sided", 0, paired = TRUE) # fails but 
if y = NULL the value of paired should not matter should it?

For y, help says "y an optional (non-empty) numeric vector of data 
values". I take this to imply that x = compared to a population mean 
hypothesis whenever y = NULL. Why should the value of paired influence 
the outcome?

Just bad memory  on my part?

R.version _ platform x86_64-w64-mingw32 arch x86_64 os mingw32 crt ucrt 
system x86_64, mingw32 status major 4 minor 5.1 year 2025 month 06 day 
13 svn rev 88306 language R version.string R version 4.5.1 (2025-06-13 
ucrt) nickname Great Square Root


-- 
---
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A.T. Still Univerisity of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501

	[[alternative HTML version deleted]]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.