Skip to content
Prev 271339 / 398498 Next

Multiple t.test

Dear R experts,

Suppose I have an data frame likes this:
age height disease
1   1    100    TRUE
2   2    110    TRUE
3   3    120    TRUE
4   4    130   FALSE
5   5    140   FALSE
6   6    150   FALSE

Is there anyway to compare the age and height between those with
disease=TRUE and disease=FALSE using t.test and extract the p-values
quickly?

I can do this individually

t.test(example$age~example$disease)[3]

But when the number of variable grow to something like 200 it is not
easy any more.

Thanks!

Regards,

CH