Solved – Column Means Significance Tests in R

New to the site. I am just getting started with R, and want to replicate a feature that is available in SPSS.

Simply, I build a "Custom Table" in SPSS with a single categorical variable in the column and many continuous/scale variables in the rows (no interactions, just stacked on top of each other).

The table reports the means and valid N's for each column (summary statistics are in the rows), and select the option to generate significance tests for column means (each column against the others) using alpha .05 and adjust for unequal variances.

Here is my question.

How can I replicate this in R? What is my best option to build this table and what tests are available that will get me to the same spot? Since I am getting used to R, I am still trying to navigate around what is available.

As I read in help for the t.test, it is only applicable for the 2-sample tests. If you want to perform it to every combination of the columns of a matrix A, taken 2 at a time, you could do something like this (for the moment, I can't recall a better way)

apply(combn(1:dim(A)[2],2),2,function(x) t.test(A[,x[1]],A[,x[2]]))  

or, if you just want the p.values

t(apply(combn(1:dim(A)[2],2),2,function(x) c(x[1],x[2],(t.test(A[,x[1]],A[,x[2]]))$p.value))) 

Similar Posts:

Rate this post

Leave a Comment