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.
Best Answer
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:
- Solved – Test if differences between frequencies is significant
- Solved – How to report results from a linear mixed model “test of fixed effects” in SPSS
- Solved – Is a Fisher’s Exact test in a 7×9 contingency table feasible
- Solved – Can SPSS perform chi-square test on an existing contingency table
- Solved – How IBM SPSS calculates exact p value for Pearson Chi-Square statistic