我有这个数据集:
Defects.I Defects.D Treatment
1 2 A
1 3 B
我正在尝试对检测到和隔离的缺陷进行描述性统计,按治疗分组。在搜索了一段时间后,我在psych
名为 describeBy() 的库中找到了一个不错的函数。使用以下代码:
describeBy(myData[1:2],myData$Treatment)
我得到了这个输出:
Treatment A
Mean. Median. Trimed.
Defects.I x x x
Defects.D x x x
Treatment B
Mean. Median. Trimed.
Defects.I x x x
Defects.D x x x
但实际上我正在寻找类似的东西
Mean. Median. Trimed.
A B A B A B
Defects.I x x x x x x
Defects.D x x x x x x
数据
myData <- structure(list(Defects.I = c(1L, 1L), Defects.D = 2:3, Treatment = c("A",
"B")), .Names = c("Defects.I", "Defects.D", "Treatment"), class = "data.frame", row.names = c(NA,
-2L))