how to t test hwo means in r code example Example: R new column t test p-value data$PValue = apply(data, 1, function(x) t.test(x[1:3], x[4:6])$p.value)