I have a dataframe with one factor column with two levels, and many numeric columns. I want to split the dataframe by the factor column and do t-test on the colunm pairs.
Using the example dataset Puromycin I want the result to look something like this:
Variable Treated Untreated p-value Test-statistic CI of difference****
Conc 0.3450 0.2763 XXX T XX - XX
Rate 141.58 110.7272 xxx T XX - XX
I think I am looking for a solution using PLYR that can an output the above results in a nice dataframe.
(The Puromycin only contains two numeric variables, but the solution I am looking for would work on a dataframe with many numeric variables)
UPDATE - I will try to clarify what i mean.
I would like to go from data that look like this:
Grouping variable var1 var2 var3 var4 var5
1 3 5 7 3 7
1 3 7 5 9 6
1 5 2 6 7 6
1 9 5 7 0 8
1 2 4 5 7 8
1 2 3 1 6 4
2 4 2 7 6 5
2 0 8 3 7 5
2 1 2 3 5 9
2 1 5 3 8 0
2 2 6 9 0 7
2 3 6 7 8 8
2 10 6 3 8 0
To a result dataframe that look like this:
"Mean in group 1" "Mean in group 2" "P-value of difference" "N"
var1 ## ## ## ##
var2 ## ## ## ##
var3 ## ## ## ##
var4 ## ## ## ##
var5 ## ## ## ##
Maybe it is something with mapply I am looking for because i want to split up my dataframe into dataframe1 and dataframe2 by a two-level factor, and apply a function( t-test) to the first parts of dataframe1 and dataframe2, and then a t-test on the second parts of dataframe1 and dataframe2, and then a t-test to the third parts of dataframe1 and dataframe2, and so on on all the column-pairs generated by the split by factor.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…