我有一个df:
df:
Uttaxeringskassa Delägare.Totalt Delägare.AndelKvinnor Utgifter.SjukhjälpPerMedlem
6877 0 207 31.400966 10.6908213
3590 1 402 NA 5.1019900
3591 1 351 12.432420 8.2592593
3592 1 378 11.838330 9.0529101
3593 1 393 NA 7.1246819
3594 1 402 16.454333 7.6791045
3595 1 403 NA 6.7890819
3596 0 401 NA 5.3341646
3597 0 39 15.384615 2.2307692
3598 0 39 15.384615 2.9230769
3599 0 38 13.157895 0.6315789
3600 0 37 10.810811 2.9729730
3601 0 35 5.714286 2.7714286
Dput
:
structure(list(Uttaxeringskassa = c(0, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0), Delägare.Totalt = c(207, 402, 351, 378, 393, 402,
403, 401, 39, 39, 38, 37, 35), Delägare.AndelKvinnor = c(31.4009661835749,
NA, 12.43242, 11.83833, NA, 16.454333, NA, NA, 15.3846153846154,
15.3846153846154, 13.1578947368421, 10.8108108108108, 5.71428571428571
), Utgifter.SjukhjälpPerMedlem = c(10.6908212560386, 5.10199004975124,
8.25925925925926, 9.05291005291005, 7.12468193384224, 7.67910447761194,
6.78908188585608, 5.33416458852868, 2.23076923076923, 2.92307692307692,
0.631578947368421, 2.97297297297297, 2.77142857142857)), .Names = c("Uttaxeringskassa",
"Delägare.Totalt", "Delägare.AndelKvinnor", "Utgifter.SjukhjälpPerMedlem"
), row.names = c("6877", "3590", "3591", "3592", "3593", "3594",
"3595", "3596", "3597", "3598", "3599", "3600", "3601"), class = "data.frame")
我想为每列计算一个 t.test 以获取均值差异,其中我对以 hh$Uttaxeringskassa 中的值为条件的列进行分组。
我正在考虑先融化df:
hhmelt=melt(hh,id.vars="Uttaxeringskassa",
variable.name="Variables",value.name="Value")
然后为所有列计算每列中均值差异的成对 t 检验。
有什么建议么?
此致