I have a dataset that looks like this
Id age memory_score
1 young 71.11172
2 old 67.65542
3 young 65.34716
4 young 81.21345
5 old 80.72106
6 old 73.01981
I want to do an independent T-test to test the hypothesis that younger people have a higher memory score than middle-aged or older people.
This is the code that I tried, but unfortunately it gives me an error called: grouping factor must have exactly 2 levels. I want to know how I can resolve this.
t.test(PU6_exercise_data1$age ~ PU6_exercise_data1$memory_score, var.equal = TRUE)