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

邮差的信 提交于 2019-12-14 02:26:49

问题


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:


We can try with pairwise.t.test

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


来源:https://stackoverflow.com/questions/41442344/how-do-i-make-a-t-test-across-several-groups-in-one-column-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!