我正在進行marascuilio程序,以比較比例之間的差異。 我使用下面的代碼(複製和改編this tutorial:Marascuilo程序中R
## Set the proportions of interest.
p = c(0.3481, 0.1730, 0.4788)
N = length(p)
value = critical.range = c()
## Compute critical values.
for (i in 1:(N-1))
{ for (j in (i+1):N)
{
value = c(value,(abs(p[i]-p[j])))
critical.range = c(critical.range,
sqrt(qchisq(.95,3))*sqrt(p[i]*(1-p[i])/12000 + p[j]*(1-p[j])/12000))
}
}
round(cbind(value,critical.range),3)
我需要輸出將同時打印類別的標籤(例如,它們正好被比較的類別)
所以如果這些類別的分離式向量上市,如categories <- c("cat1", "cat2", cat"3)
,攀比是cat1-cat2
,cat1-cat3
,並cat2-cat3
。
我怎麼能這些標籤附加到我的輸出?
value critical.range
[1,] 0.175 0.016
[2,] 0.131 0.018
[3,] 0.306 0.016
又該輸出數據框的樣子在上面的例子嗎? – thepule
我添加了一個例子,所以基本上應該添加另一列,並攜帶有關類別比較的信息 –