Assuming your data frame looks something like this:
df = data.frame(a=runif(100), b=runif(100), c=runif(100), d=runif(100), e=runif(100), f=runif(100))
follows the following
tests = lapply(seq(1,length(df),by=2),function(x){t.test(df[,x],df[,x+1])})
will give you tests for each set of columns. Note that this will only give you t.test for a and b, c and d, and e and f. if you want a and b, b and c, c and d, d and e, and e and f, you will need:
tests = lapply(seq(1,(length(df)-1)),function(x){t.test(df[,x],df[,x+1])})
Finally, if you say that you want only the P values ββfrom your tests, you can do this:
pvals = sapply(tests, function(x){x$p.value})
If you donβt know how to work with the object, try entering a summary (tests) and str (tests [[1]]) - in this case test is a list of htest objects, and you want to know the structure of the htest object, not necessarily a list.
Hope this helps!