Questions tagged [combn]

121 questions
0
votes
1 answer

How to multiply all possible combinations of columns in R and use them into a multiple linear regression model?

Suppose I have three columns in a data frame A, B and C respectively. The number of rows for each column are 10. Now, I want to multiply all possible combinations of the columns by taking 2 at a time. So, the columns that I want are AB, AC,BC. How…
T_S
  • 3
  • 2
0
votes
1 answer

How would I find the number of correlations exceeding a threshold in more than 50% of that variables correlations using the output from combn?

I have a large data frame, where I use combn to get the unique combinations between each pair of variables. So the output looks as follows ( with a small example of only 7 variables). The problem I have is that I wish to identify which features have…
0
votes
1 answer

combn to run a t.test on only one row in a data.table, based on the grouping of another row

For this question, I'm using example data from another question: (Using combn() in R to find all possible t-test relationships, how to access the variables compared?) I am trying to run t.tests on the data in one column (vdem_media_bias) based on…
Chris
  • 150
  • 14
0
votes
0 answers

How to reverse combn in R to get the unique list of column names?

I have a large data frame which I have used combn to generate the number of unique combinations (over 100,000). Once I get the results from the correlation test ( estimate, p value) and I undertake some filtering, I remove some of the combintations.…
0
votes
1 answer

Creating a dataset (data frame,df) in R consisting of all possible combinations of 10 different variables

Thanks in advance for any advice. As part of a study, I need to: Part 1: I need to create a .csv dataset (or r data frame?) that produces all possible combinations of 10 different variables. Each of the 10 variables has either 2 (i.e., binary 0,1)…
Bob_123
  • 19
  • 3
0
votes
0 answers

How to fix vector size discrepancy(?): lmeInfo::g_mlm function, between r_const and utils::combn(1:cor_q, 2) : n < m

Using this code block in fresh install of R, if (!require('readr')) install.packages('readr') data <- as.data.frame(readr::read_delim("/Users/{le me}/Desktop/{path}/Histology Data for R.csv", delim = ",")) DataGroupLabel <- "3groupAnova" subdata <-…
0
votes
0 answers

R group by distinct pairs within a column and then count

I have a data frame containing two columns - ID and SHOP, and I want to find the count of unique Customer IDs that correspond to unique combination of shops in the Shop column. My original data frame is as…
stump
  • 85
  • 1
  • 6
0
votes
2 answers

Simplify output for combn function to remove spaces and row and column markers

I would like to take a data set like the one below generated using the combn function: https://i.ibb.co/r0qSmYV/example.jpg and have it print 1111112223 2223343344 3454544555 the current solutions I have tried are trimws() and gsub(). Any help will…
0
votes
1 answer

Error by looping combn - function (multiple Dataframes)

I've have a hard time to get a function within a function for multiple Dataframes. I have multiple Dataframes: all looks like A <- data.frame(Date = as.character(c("Jan-22", "Dec-21", "Nov-21", "Oct-21")), City1 = seq(1:4), …
Sulz
  • 333
  • 1
  • 8
0
votes
3 answers

how to optimize the use of `expand.grid` or `combn` in R

I have a vector of characters v <- c("piment","aubergine","carotte","oignon","chou","pommeDeTerre") and I would like to combine them to prepare a complete experimental design. So I want to produce a data.frame with for each line a set of n elements…
delaye
  • 1,357
  • 27
  • 45
0
votes
1 answer

Create combination of all elements in a list

I am creating a function that requires the user to enter the input variables and then the function creates all possible combinations (of varying lengths) of those input parameters. Lets say input variables are "A", "B", and "C". Combination…
kav
  • 85
  • 6
0
votes
1 answer

Finding the most common pairs by row of 5 variables, summarized by group, in a df

I am trying to find the most common pairs across 5 variables, very similar to this question. The main difference is I'd have one more variable that I'd like to group them by. data.frame': 430 obs. of 6 variables: $ group: chr "Celtics"…
0
votes
2 answers

Using combn() in R to find all possible t-test relationships, how to access the variables compared?

So, I have a DataFrame with a large number of variables, and I want to cross-check each variable with each other variable with a t-test. A sample of my data, called…
0
votes
2 answers

How to apply the combn() function to a column of list type?

I have a dataframe with 3 columns, one of which is of list type >head(basket_data) # A tibble: 8 x 3 order_id items count 1 2 9 2 3 8 3 4 13 4 …
kenneth-rebello
  • 914
  • 1
  • 7
  • 13
0
votes
2 answers

R: Split a dataframe into n partition and recombine them in all possible combination of partitions

I have dataframe with 6 columns and I want to partition them into 3 parts each with 2 columns. I want to recombine partitions in all possible combinations to create 7 new…
user3311147
  • 281
  • 2
  • 5
  • 16
1 2 3
8 9