Questions tagged [combn]
121 questions
1
vote
0 answers
How can I handle a very large number of combinations in R?
Here is my problem - I would like to generate a fairly large number of factorial combinations and then apply some constraints on them to narrow down the list of all possible combinations. However, this becomes an issue when the number of all…

Nicolas K
- 111
- 3
1
vote
3 answers
Increase speed for operations using a combination of "combn" and "outer" functions
I have a dataframe, df with two variables as given below. Using the code below, I want to get matrix "mat".
This code works perfect for unique(df$V1)= 3 but it takes a lot of time (>10 hours) for operations where unique(df$V1) is in…

vp_050
- 583
- 2
- 4
- 16
1
vote
1 answer
Using combn function to create tables and label each table based on its combination
I have some data which looks like:
# A tibble: 10 x 7
XGBoost Logistic NN RandomForest SVMRadial SVMLinear LightGBM
1 Correct Correct Correct Correct …

user113156
- 6,761
- 5
- 35
- 81
1
vote
1 answer
comb with sum function across the columns of a dataframe
I have the dataframe DATA with the first 5 rows shown:
>dput(DATA)
structure(list(e_1 = c(21.8, 21.8, 21.8, 21.8, 21.8),
e_2 = c(9.8, 9.8, 9.8, 9.8, 9.8), e_3 = c(-2.2, -2.2, -2.2,
-2.2, -2.2), e_4 = c(-14.2, -14.2, -14.2, -14.2, -14.2),
e_5 =…

Maral Dorri
- 468
- 5
- 17
1
vote
2 answers
Create samples from the output of a combn function in R, with no repeated elements
I am trying to solve this problem with R: out of all possible combinations of letters, I want to randomly select a sample of 13 pairs with the condition that no LETTER is repeated.
I am trying the following:
x<- LETTERS
combi <- combn(x, 2, FUN =…

AJS
- 25
- 6
1
vote
3 answers
R: implement combn function with several m and define output variables
I am using the following code to obtain the mean of all possible combination (m=2) of the variables whose name starts with "form".
k=which(grepl("^form",colnames(data)))
combined <- combn(data[,k], 2, FUN = rowMeans)
colnames(combined) <-…

Mariano C Giglio
- 125
- 8
1
vote
1 answer
R: combn function and define names of generated variables
I have a data frame named “dat” with 5 numeric variables (var1, var2,var3,var4 , var5), each with 20 observations.
structure(list(var_1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20), var_2 = c(7, 8, 9, 10, 11, 12,
13,…

Mariano C Giglio
- 125
- 8
1
vote
1 answer
How can I create a list of letters/numbers with a specific repeating pattern?
Basically I have 25 96-well plates and I need to create a list of every possible well where P = plate, the next number is the plate number (1-25), the next letter corresponds to the row on the plate (A-H), and the last number corresponds to the…

Beth L.
- 11
- 1
1
vote
1 answer
How to iteratively perform combinations on larger datasets?
Background - I want to try and exhaustively search a set of all possible combinations of 250 rows taken 10 at a time. In order to iteratively get this, I use the following code
`
## Function definition
gen.next.cbn <- function(cbn, n){
##…

Kannan Subramanian
- 230
- 1
- 10
1
vote
2 answers
List of all combinations of a minimum value using combn
Here is my data:
[,1] [,2] [,3]
[1,] 2 3 4
[2,] 2 3 5
[3,] 2 3 6
[4,] 2 4 5
[5,] 2 4 6
[6,] 2 4 2
[7,] 2 4 4
[8,] 2 4 9
[9,] 2 4 10
[10,] 2 4 3
How would…

Aesler
- 181
- 10
1
vote
1 answer
Create all combinations of items with many items
I want to have the possible combinations for a variety of items. Think of participants bringing one of three items to an event, and I want to know the different combinations (order of participants don't matter). For instance,
items <-…

coffeinjunky
- 11,254
- 39
- 57
1
vote
1 answer
split a dataframe and create many data frames or list
I want to create a list or many data.frame from a dataframe at the same time after splitting a matrix. I am using the function combn to create a matrix.
For instance:
combos<-combn(1:3, 2)
combos
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 2 …

Leandro Jimenez
- 99
- 9
1
vote
0 answers
Best way to manage large sets of combinations in R
I'm hoping to get some advice about managing large sets of combinations in R.
I'm a plant breeding graduate student attempting to calculate the highest ranked average values of the progenies of various combination of 40 parents in a plant…

Jared Zystro
- 11
- 2
1
vote
1 answer
Performing a function on all possible combinations of a subset of DF columns in R
I'd like to calculate the distance between row-wise pairs of lat/long coordinates. This is easily done with a variety of functions like earth.dist. Where I am stuck is that I'd like this to be part of a nightly data quality check process where the…

Derek Darves
- 192
- 1
- 5
1
vote
2 answers
combn() function in r
I'm trying to perform the dot product on all possible combinations of vectors. I am able to find all the possible combinations. I just can't quite figure out how the FUN argument in combn() works. Below is my code, thanks for any…

Brent Ferrier
- 312
- 1
- 4
- 18