0
$\begingroup$

I will like to perform and statistical comparison between 3 groups, in order to determine if statistically they are different or not. My data for all of the 3 groups follows a normal distribution. I am aware that in order to test for statistical significance, one can use the t.test function in r; however, that only allows to compare two groups. So, I was wondering if there is test to test such statistical difference in these 3 groups that I have.

So far my code is the following:

groups<- read.csv("...",header=TRUE)
head(groups)
str(groups)
t.test(groups$ï..Group.A,groups$Group.B) 

Output of str(groups)

> str(groups)
'data.frame':   20 obs. of  3 variables:
 $ ï..Group.A: num  0.16 -1.32 -0.409 0.128 0.844 ...
 $ Group.B   : num  0.1673 -0.1368 1.3216 -0.0506 0.1097 ...
 $ Group.C   : num  1.852 0.707 0.338 -0.327 1.109 ...

Thank you

$\endgroup$
4
  • 1
    $\begingroup$ See this guide and links within. You can use _e.g._anova, kruskal.test, pairwise.t.test. $\endgroup$
    – neilfws
    Commented Jul 9, 2019 at 4:31
  • $\begingroup$ No doubt there are many more duplicates on site $\endgroup$
    – Glen_b
    Commented Jul 9, 2019 at 6:26
  • $\begingroup$ Just to point out , the question was asked first in Stack Overflow, then it was migrated to here. As my profile indicates, I am not a regular user of Cross Validated; however, I appreciate the answer. @Glen_b $\endgroup$
    – Perro
    Commented Jul 10, 2019 at 4:41
  • $\begingroup$ The reference to more duplicates indicate that you can use the search feature to find additional information. $\endgroup$
    – Glen_b
    Commented Jul 10, 2019 at 13:00

1 Answer 1

0
$\begingroup$

As mentioned by neilfws in the comments, you can use an ANOVA. Put the data in standard format, that is all the values in one columns, and create one variable which determines the group.

> summary(aov(mpg~factor(gear),data=mtcars))
             Df Sum Sq Mean Sq F value   Pr(>F)    
factor(gear)  2  483.2  241.62    10.9 0.000295 ***
Residuals    29  642.8   22.17                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.