jeudi 18 juin 2015

From randomly to not randomly selecting columns

I have this piece of script for R and I want to adjust it a little bit.

Here's the script I have, mydata is an imported .csv file of n columns:

libary(orddom)
R=6
delta = numeric (R)
for (i in 1:R) {`
a <- data.matrix(sample(mydata, 2, replace=FALSE)) 
drops <- c(colnames(a)) 
b <- data.matrix(mydata[,!(names(mydata) %in% drops)]) 
a1 <- na.omit(t(matrix(a,1)))
b1 <- na.omit(t(matrix(b,1)))
colnames(a1) <- c("Group 1")
colnames(b1) <- c("Group 2")
delta [i] <- abs(as.numeric(orddom(a1, b1, alpha = 0.05, paired=FALSE)[13,1]))

The problem is that for vector a, the columns of mydata get resampled randomly, leading to several equal delta values, because every time the iterative process start again there is a possibility that the same set of columns get selected. But now I want the columns to be not randomly resampled. So I want all the possible column combinations, column 1 and 2 and 3 is the same combination as column 2 and 1 and 3 and so on, avoiding combinations of one column with itself, without repetition. (Is there a way to exclude column combinations that have already been selected before?)

And then I would like to calculate delta for every combination and store it in a vector.




Aucun commentaire:

Enregistrer un commentaire