![]() |
VOOZH | about |
The two-sample t-test compares the means of two independent groups. It checks whether the difference between these means is statistically significant. We often use this test when comparing results between two separate groups, like the heights or test scores of students in different classes.
Syntax:
t.test(x, y, alternative = "two.sided", mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95)
Parameters:
We want to compare the heights of two groups of students, male and female, to see if there's a significant difference in their average heights.
We first create two numeric vectors to represent the data for each group.
We use the t.test() function to compare the two groups. This function performs the test and returns results like the p-value and confidence interval.
Output:
We use the p-value to decide if there is a significant difference. If the p-value is less than 0.05, we say the difference is statistically significant.
Output:
[1] "There is a significant difference in the average heights of male and female students."
The two-sample t-test is a handy way to compare averages between two groups.