Independent t-test
This lesson is called Independent t-test, part of the Inferential Statistics with R course. This lesson is called Independent t-test, part of the Inferential Statistics with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Your Turn
Perform an independent samples t-test to test whether there is a difference in
exam_1
byathlete
. Usevar.equal = TRUE
. Is there a difference? What is the p-value?Perform an independent samples t-test to test whether there is a difference in
act_english
bygender
. Usevar.equal = TRUE
. Is there a difference? What is the p-value?
Notice what happens since gender has 3 levels. Try out using the filter()
function from dplyr
to only check the difference between Female and Male students. Alternatively, check out the page on t_test()
to see how to use the comparisons
argument to specify the groups to compare.
Learn More
Have any questions? Put them below and we will help you out!
Course Content
21 Lessons
You need to be signed-in to comment on this post. Login.
gene trevino • January 26, 2025
Just curious why my output is not in the same format as yours. This is how mine appears.
.y. group1 group2 n1 n2 statistic df p
Thanks
David Keyes Founder • January 27, 2025
We'd have to see your exact code to be able to give you an answer.
gene trevino • January 27, 2025
college %>% select(exam_1, exam_2) %>% pivot_longer(cols = everything(), names_to = "exam", values_to = "score") %>% t_test(score ~exam, paired = TRUE)
Thanks, Gene Trevino
David Keyes Founder • January 29, 2025
I believe the difference is because Dana is displaying her output using a table function. The difference is merely aesthetic though – the output is identical to yours.
gene trevino • January 29, 2025
How can I learn about the table function ?
David Keyes Founder • January 29, 2025
These slides are made with the {xaringan} package. You can learn about that in my book. In terms of options to make tables, see this blog post. There are many packages to make tables. I typically recommend {gt} and {flextable}.