0

I managed to find what I needed to do in a post: https://stackoverflow.com/a/13802263/4127865

Reproduced here for reference:

df <- read.table(text="Group   var1    var2    var3    var4    var5
1           3   5   7   3   7
1           3   7   5   9   6
1           5   2   6   7   6
1           9   5   7   0   8
1           2   4   5   7   8
1           2   3   1   6   4
2           4   2   7   6   5
2           0   8   3   7   5
2           1   2   3   5   9
2           1   5   3   8   0
2           2   6   9   0   7
2           3   6   7   8   8
2           10  6   3   8   0", header = TRUE)


t(sapply(df[-1], function(x)unlist(t.test(x~df$Group)[c("estimate","p.value","statistic","conf.int")])))

However, I am extremely confused over why the need to unlist the t.test function.

Question: What is the function of unlist in this case?

Thank you

Community
  • 1
  • 1
Raphael Lee
  • 111
  • 1
  • 10
  • 2
    Remove `unlist` from the answer and see what you get. The estimate and confidence interval results from a `t.test` are not single values and cause the output matrix to have embedded lists. – thelatemail Jun 03 '16 at 01:02
  • Thank you very much. I will experiment as a good starting point. – Raphael Lee Jun 03 '16 at 01:10

0 Answers0