23 lines
650 B
R
23 lines
650 B
R
|
|
gendat <- function(i, ncols, nrows) {
|
|
set.seed(i * nrows * ncols)
|
|
|
|
# all configurations BUT the outcome have to be unique
|
|
dat <- unique(
|
|
matrix(sample(0:1, (ncols - 1)*nrows, replace = TRUE), ncol = ncols - 1)
|
|
)
|
|
|
|
# now that configurations are unique, we can add the outcome
|
|
dat <- cbind(dat, sample(0:1, nrow(dat), replace = TRUE))
|
|
|
|
if (ncols > length(LETTERS) + 1) {
|
|
colnames(dat) <- c(
|
|
paste("I", seq(ncols - 1), sep = ""),
|
|
"OUT"
|
|
)
|
|
} else {
|
|
colnames(dat) <- c(LETTERS[seq(ncols - 1)], "OUT")
|
|
}
|
|
|
|
return(dat[order(dat[, ncols], decreasing = TRUE), ])
|
|
}
|