[R] suggestion for paired t-tests

Jack Tanner ihok at hotmail.com
Fri Jul 24 22:55:18 CEST 2009


There's a funny inconsistency in how t.test handles paired=T or paired=F. If x
and y parameters are lists, paired=F works, but paired=T doesn't.

> lg=read.csv("my.csv")
> a = subset(lg, condition=="a")["score"]
> b = subset(lg, condition=="b")["score"]
> t.test(a,b)
> t.test(a,b, paired=TRUE)
Error in `[.data.frame`(y, yok) : undefined columns selected

But this works
> a=a[,1]
> b=b[,1]
> t.test(a,b, paired=TRUE)
...




More information about the R-help mailing list