I have this dataframe:
I'm performing a t_test using this lapply approach:
columns = colnames(my_data)[-1]
my_t_test<-lapply(my_data[columns], function(x) t.test(x~my_data$Treatment,alternative='less'))
But it seems the t_test take x=my_data$Control
and y=my_data$Stress
, making the results a non-sense. As I'm testing the alternative hypothesis that the difference in the mean is less in the $Stress
group, I want that the x argument will be my_data$Stress
. And option is to change to alternative='greater'
, but is an awful approach, the other option is to change the order of the groups in my dataframe, but I´m looking for a programmatic solution.
any suggestion?