combinations <- function(chooseK, nameFeature){
if(round(chooseK) != chooseK || chooseK <= 0){
stop("chooseK must be a positive integer.")
}
## Initialize output
combinations <- vector("list", length=chooseK)
## Populate combinations of each N choose K
for(i in 1:chooseK){
combinations[[i]] <- t(combn(chooseK, i, function(x) {z=integer(chooseK);z[x]=1;z}))
}
combinations <- do.call(rbind, combinations)
colnames(combinations) <- nameFeature
return(combinations)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.