combinations

Get all possible string sequences where each element comes from different set in R

天涯浪子 提交于 2019-12-25 02:57:37
问题 Assume I have 4 vectors of character elements: s1 <- c("o", "ó") s2 <- c("c", "ć") s3 <- c("o", "ó") s4 <- c("z", "ź", "ż") I want to build 4-element vectors that are all possible combinations of elements from s1 , s2 , s3 , s4 in a way that in one of a result vectors 1-st, -2nd, 3-rd and 4-th element comes from s1 , s2 , s3 , s4 , respectively. For example, I would like to get the following result vectors: [1] "o", "c", "o", "z" [1] "ó", "c", "o", "z" [1] "o", "ć", "o", "z" ... [ My general

find combination pairs of attribute variables

徘徊边缘 提交于 2019-12-25 01:53:15
问题 I looked around for a solution but could not find an exact one. Given: a<-c('a','b','c') b<-c('d','e','f') d<-c('g','h') as a toy subset of a much larger set, I want to be able to find unique pairs between attribute (vector) sets. If I use combn(c(a,b,d),2) It would return ALL pairwise combinations of all of the attribute elements. e.g. combn(c(a,b,d),2) returns c(a,b) c(a,d) c(a,d) c(a,e)... But I only want pairs of elements between attributes. So I would not see a,b or a,c but a,d a,e a,f b

Function to generate the unique combinations of a list in Haskell

房东的猫 提交于 2019-12-25 01:04:12
问题 Is there a Haskell function that generates all the unique combinations of a given length from a list? Source = [1,2,3] uniqueCombos 2 Source = [[1,2],[1,3],[2,3]] I tried looking in Hoogle but could not find a function that did this specifically. Permutations does not give the desired result. Has anybody used a similar function before? 回答1: I don't know a predefined function either, but it's pretty easy to write yourself: -- Every set contains a unique empty subset. subsets 0 _ = [[]] --

Google Sheets - Function to combine cells in a column into two columns with all possible combinations?

强颜欢笑 提交于 2019-12-25 01:00:22
问题 Can anyone help me write a Google Sheets function for doing this: Google Sheets example of what needs to be done: The first column could be filled with X lines with a name in each one. From that names, the columns "target" and "source" would be filled with all possible combinations between the names , without repeating a pair (if you already have "Gustavo | Jacinto", you don't need "Jacinto | Gustavo"). I know I can solve this problem using python and other stuff, but I wanted to do this

how to produce every permutation of 20 one (-1) in a 1-by-41 vector of ones and a simple calculation on each row?

无人久伴 提交于 2019-12-25 00:46:56
问题 I want to produce all permutations of 20 minus one(-1) and 21 one(1) this matrix has 269128937220 rows and 41 columns. and I want to do the following calculation on each row of this matrix: (SLS')/4 where: S is each row of this matrix(a 1 by 41 array). S' is the transpose of S(a 41 by 1 array). L is a 41 by 41 matrix the final result of each calculation is a single number. is there any way to produce this matrix and do the calculation without getting out of memory error and in a reasonable

How to make combination in drilldown in highcharts / add outliers in boxplot in drilldown?

故事扮演 提交于 2019-12-25 00:35:55
问题 I asked one question recently, but this is a new, relevant yet total different one. I would like to add outliers in boxplot which is in drilldown. I am able to do that in primary plot, in a combination way that boxplot is in one series while outliers are in another series as 'scatter'. As in follows: series : [ {type : 'boxplot' , ...} , {type : 'scatter' ,...} ] But as now my boxplot is in drilldown, whose series denotes different drilldowns/figures, I can not add outliers in boxplot. As in

R: Update adjacency matrix/data frame using pairwise combinations

半城伤御伤魂 提交于 2019-12-24 20:46:09
问题 Question Let's say I have this dataframe: # mock data set df.size = 10 cluster.id<- sample(c(1:5), df.size, replace = TRUE) letters <- sample(LETTERS[1:5], df.size, replace = TRUE) test.set <- data.frame(cluster.id, letters) Will be something like: cluster.id letters <int> <fctr> 1 5 A 2 4 B 3 4 B 4 3 A 5 3 E 6 3 D 7 3 C 8 2 A 9 2 E 10 1 A Now I want to group these per cluster.id and see what kind of letters I can find within a cluster, so for example cluster 3 contains the letters A,E,D,C .

Generating nCr combinations of given set in java [closed]

懵懂的女人 提交于 2019-12-24 19:26:00
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want java implementation of generating nCr combinations of given set. e.g if set is {"java","php",".net","python"} program should return all possible nCr sets of given set. 回答1: Adapting Gosper's hack, this

Creating exhaustive case columns in SQL

核能气质少年 提交于 2019-12-24 18:57:18
问题 I am trying to generate a column "Gender Combinations" that creates exhaustive categories of interaction terms like in the table below. Is there an easy way to do this in SQL (microsoft server)? +--------------+--------------+--------------+---------------------+ | EMP 1 Gender | EMP 2 Gender | Emp 3 Gender | Gender Combinations | +--------------+--------------+--------------+---------------------+ | Male | | | 1 Male | | Female | | | 1 Female | | | Male | | 1 Male | | | Female | | 1 Female |

Custom permutation, Equal distribution of equal size groups

老子叫甜甜 提交于 2019-12-24 18:53:03
问题 I made a post a few months ago here Custom permutation, Equal distribution of pairs. I wanted to generate pairs unique to each other while never containing the same pair. I got an excellent answer from Thierry Lathuille on here with this code. def pairs(n): for diff in range(1, n): starts_seen = set() index = 0 for i in range(n): pair = [index] starts_seen.add(index) index = (index+diff) % n pair.append(index) yield pair index = (index+diff) % n if index in starts_seen: index = (index+1) % n