How do I make a t-test across several groups in one column in R?

229 views Asked by At

I'd like to kindly ask you, how to perform a t-test in R when I have a column with the group levels and a column with the values like this:

group value
north 1.1
north 1.6
north 1.4
east  1.3
east  1.5
east  1.7
south 1.2
south 1.5
south 1.8
west  1.6
west  1.7
west  1.9

to get a result like this:

      north   east    south   west
north         p-value p-value p-value
east  p-value         p-value p-value
south p-value p-value         p-value
west  p-value p-value p-value

I searched a lot in the internet but the descriptions that I have found were for only two groups or for groups in different columns. I can't imagine, that this is such a rare issue. It should be common that scientists have to compare more than two groups to see which groups are significantly different from each other.

Thanks for your help and greetings

1

There are 1 answers

0
akrun On BEST ANSWER

We can try with pairwise.t.test

pairwise.t.test(df1$value, df1$group)$p.value