Re: [R] Looping through all possible combinations of cases

2007-07-31 Thread Adrian Dusa
Here is another (simpler?) solution: # your 1 column data is actually a vector myvalues <- 1:10 names(myvalues) <- LETTERS[1:10] # use the QCA package library(QCA) aa <- createMatrix(rep(2, length(myvalues))) # set the number of combinations: 2, 3, 4 or whatever combinations <- 2 sub.aa <- aa[ro

Re: [R] Looping through all possible combinations of cases

2007-07-30 Thread jim holtman
Here is how to do it for 2; you can extend it: > # test data > n <- 100 > x <- data.frame(id=sample(letters[1:4], n, TRUE), values=runif(n)) > # get combinations of 2 at a time > comb.2 <- combn(unique(as.character(x$id)), 2) > for (i in 1:ncol(comb.2)){ + cat(sprintf("%s:%s %f\n",comb.2[1,i],

Re: [R] Looping through all possible combinations of cases

2007-07-30 Thread Charles C. Berry
Lots of ways. Here is a simpler one. start by reading ?combn ?subset ?Subscript ?is.element ?apply ?paste - note the 'collapse' arg ?names - note the 'names(x) <- value' usage ?list ?unlist then write a function that calc's

[R] Looping through all possible combinations of cases

2007-07-30 Thread Dimitri Liakhovitski
Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to wri