Created
July 26, 2017 06:32
-
-
Save rmporsch/cc3cdae2eb9f4fffcad92a826f8d21cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make.lists <- function (mat) { | |
traits <- mat[,1] | |
prs <- mat[,2] | |
d <- t(combn(c(traits, prs), 2)) | |
d <- rbind(d, d[, c(2,1)]) | |
out <- vector() | |
i <- 1 | |
for (i in 1:nrow(d)) { | |
temp <- d[i,] | |
if ((temp[1] %in% traits) && (temp[2] %in% traits)) { | |
out <- append(out, i) | |
next | |
} | |
numb.trait <- which(mat==temp[1], arr.ind=T)[,'row'] | |
numb.prs <- which(mat==temp[2], arr.ind=T)[,'row'] | |
if ((temp[1] %in% prs) && (temp[2] %in% traits) && (numb.trait==numb.prs)) { | |
out <- append(out, i) | |
} | |
} | |
white <- d[out,] | |
black <- d[!c(1:nrow(d))%in%out,] | |
return(list(white, black)) | |
} | |
message("Function 'make.lists()' loaded") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment