T.Test across several columns at once?

78 views Asked by At

I'm attempting to do a T-Test across many different columns at once, but can't figure out how to do it. Here is what I have for one of the columns, Clout.

t.test(wf[wf$ThreadID == 249001,]$Clout,wf[wf$ThreadID == 230005,]$Clout)

But I have about 20 other columns, e.g. Authentic, Tone

How can I run this test across all columns?

1

There are 1 answers

4
Rui Barradas On BEST ANSWER

Try the following.

n <- ncol(wf)
inx1 <- which(wf$ThreadID == 249001)
inx2 <- which(wf$ThreadID == 230005)
ttest_list <- lapply(seq_len(n), function(j) t.test(wf[inx1, j], wf[inx2, j]))

Note: How can you be sure that there are as many elements such that wf$ThreadID == 249001 and wf$ThreadID == 230005?