I am trying to run a two-sample t-test for a difference between a treatment and control group. Data is not paired. When I subset my original dataframe, I found that I have unequal sample sizes (not an issue by hand, but R seems to make it an issue). Here is my code:
CG<-subset(data,treat=="Control")
TG<-subset(data,treat!="Control")
agep <-t.test(CG$age~TG$age)$p.value
The error I get is the following:
Error in model.frame.default(formula = CG$age ~ TG$age) :
variable lengths differ (found for 'TG$age')
Yes! The lengths do differ. Not sure why that's a problem if I'm not running a paired test? Thanks in advance for any help.