Displaying 2 results from an estimated 2 matches for "allcomb".
Did you mean:
all_comb
2008 Aug 31
4
give all combinations
Hello,
is there a simple way to give all combinations for a given vector:
v<-c("a","b","c")
combination(v,v) becomes
"aa","ab","ac","bb","bc","cc'
combination(v,v,v) becomes
"aaa","aab","aac","abb",......
[[alternative HTML version deleted]]
2006 Mar 06
1
combinatorics again
...d require a matrix of 10^10 rows, and my little linux machine
refuses to cooperate, complaining about allocating a vector of
length 1410065408. For these values of J and S, I happen to know
that the are 6360 distinct combinations, which is eminently handleable.
Anyone got any better ideas?
allcomb <- function(J,S){
f <- function(...) {
1:S
}
out <- as.matrix(do.call("expand.grid", lapply(1:J, FUN = f)))
out <- t(apply(out,1,sort))
unique(out)
}
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton...