I have about 10000 replicates of a sample in a matrix. My matrix has 1000 rows and 6 columns. Numbers in the columns range from 0:58 depending on the sample.
actual.prob <- c(.14, .14, .16, .13, .19, .24)
million.rep <- replicate(10000, sample(1:6, 58, replace= T, actual.prob))
new.matrix <- matrix(nrow= 10000, ncol=6)
for(i in 1:10000){
new.matrix[i,] <- as.vector(table(factor(million.rep[,i], levels=1:6)))
}
new.matrix[1:10,]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 3 7 11 11 11 15
[2,] 7 6 12 5 19 9
[3,] 12 7 6 8 11 14
[4,] 6 7 16 6 11 12
[5,] 5 9 12 5 14 13
[6,] 9 4 14 7 10 14
[7,] 6 9 9 6 15 13
[8,] 9 4 8 8 11 18
[9,] 6 11 7 5 12 17
[10,] 7 6 9 9 15 12
I want to find if any samples are repeated. I tried replicated() which tells me what rows are replicates, but I want to view the row without having to go back manually. Any suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…