2014-05-06 38 views
0

我必須將文章分配給各種編碼器。每篇文章應該編碼兩次,沒有一對編碼員可以獨自一起工作。按序列分配ID號碼

我估計,該方案應該是這樣的(test是什麼,我需要一個例證):

art_id <- 1:21 
coder1 <- c(1,2,3,4,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) 
coder2 <- c(1,0,0,0,0,0,7,8,9,10,11,0,0,0,0,0,0,0,0,0,0) 
coder3 <- c(0,2,0,0,0,0,0,0,0,0,0,12,13,14,15,0,0,0,0,0,0) 
coder4 <- c(0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,16,17,18,0,0,0) 
coder5 <- c(0,0,0,4,0,0,0,0,9,0,0,0,13,0,0,16,0,0,19,20,0) 
coder6 <- c(0,0,0,0,5,0,0,0,0,10,0,0,0,14,0,0,17,0,19,0,21) 
coder7 <- c(0,0,0,0,0,6,0,0,0,0,11,0,0,0,15,0,0,18,0,20,21) 

test <- data.frame(art_id, coder1, coder2, coder3, coder4, coder5, coder6, coder7) 

這顯然是可能的一個簡單的方法,但我的數學技能是相當有限的。以這種方式自動分配200篇文章有沒有「簡單」的方法? 請注意art_id將是字符,而不是像這個插圖中的數字。

謝謝。

+0

看起來像一個下三角矩陣是你想要的... –

+0

托馬斯,做我的編輯比賽,你打算配對條件? –

+0

每個編碼員都必須編寫與其他編碼一樣多的文章嗎? – Vincent

回答

1

我同意Carl Witthoft的建議,並且會建議您使用combn函數。

這裏是我的嘗試:

# Setup articles 
articles <- paste("article_", seq(1:200)) 

# Setup unique coder probabilities 
coders <- paste0("coder_", seq(1:7)) 
unique.coder.combinations <- do.call(paste, c(data.frame(t(combn(coders, 2))))) 

# Assignment 
coder.selection <- cbind(articles, coders=sample(unique.coder.combinations, 200, replace=TRUE)) 

# head(coder.selection) 
# > head(coder.selection) 
#  articles  coders   
# [1,] "article_ 1" "coder_1 coder_5" 
# [2,] "article_ 2" "coder_2 coder_4" 
# [3,] "article_ 3" "coder_4 coder_6" 
# [4,] "article_ 4" "coder_3 coder_7" 
# [5,] "article_ 5" "coder_5 coder_7" 
# [6,] "article_ 6" "coder_3 coder_4" 
+0

如果你允許'replace = TRUE',你不打算違反「不重複編碼器對」規則嗎? - 如果你有200篇文章,只有7位編碼者,你將必須做的! –

+0

在原始問題中,文本是 - 至少如果我記得是對的 - 不同。也就是說,一對編碼人員不應該一起工作,即在一組文章中,並且不能與其他編碼人員一起工作。如果您認爲OP想要控制編碼器效果,那將是有意義的。 – majom

+0

如果我的假設不正確,那麼combn就是解決方案。但是,從純粹的實踐角度來看,這對我來說沒有任何意義。 – majom

0

不確定,但我認爲走向不同的方向將做到這一點。首先計算所有可能的「編碼器配對」。

codepair <- combn(1:7,2) 

然後隨機分配您art_id值列在codepair

請注意,您需要編碼器有一定的最低數量爲對象的給定數。