Questions tagged [pairwise]
273 questions
8
votes
4 answers
Convert long-form dataframe of pairwise distances to distance matrix in python
I have a pandas dataframe of pairwise distances in the form of:
SampleA SampleB Num_Differences
0 sample_1 sample_2 1
1 sample_1 sample_3 4
2 sample_2 sample_3 8
Note that there are no…

frustrated_bioinformatician
- 353
- 2
- 10
7
votes
2 answers
How do I count the number of times any two given values occur together in a row in R?
I am working with a data frame like this, with the ID column indicating a specific publication:
ID AuthorA AuthorB AuthorC
1 Chris Lee Jill
2 Jill Tom Lee
3 Tom Chris Lee
4 Lee Jill NA
5 Jill Chris NA
I…

Frowin Becker
- 203
- 1
- 4
7
votes
1 answer
How to identify duplicated ordered pairs efficiently
I'm working with origin-destination (OD) data that contains an origin ID and a destination ID in separate columns. Sometimes it's important to aggregate OD pairs that are the same, except that the origin and destination is swapped.
OD data looks…

RobinLovelace
- 4,799
- 6
- 29
- 40
6
votes
15 answers
Finding index of pairwise elements
Given the target ('b', 'a') and the inputs:
x0 = ('b', 'a', 'z', 'z')
x1 = ('b', 'a', 'z', 'z')
x2 = ('z', 'z', 'a', 'a')
x3 = ('z', 'b', 'a', 'a')
The aim is to find the location of the continuous ('b', 'a') element and get the output:
>>>…

alvas
- 115,346
- 109
- 446
- 738
5
votes
3 answers
How to print on a serie sof graphs pairwise comparisons bars and effect size value?
I'm struggling to create a series of high-quality ggboxplots, like the one I attach as follows:
With labels for ANOVA with F(df) test value, p.value and effects size
With multi-pairwose comparisons bars with bars and stars with significant…

12666727b9
- 1,133
- 1
- 8
- 22
5
votes
3 answers
Kotlin: Iterate through every pair (or generally fixed-sized subsets) in collection
Is there a short/idiomatic way to iterate through every pair of elements in a collection?
Even better would be a method that iterates through all fixed-cardinality subsets of a collection.
The classic and ugly approach would be:
val s = setOf(1, 2,…

Moritz Groß
- 1,352
- 12
- 30
5
votes
2 answers
Finding Matched Pairs using each record only once in SQL Server
I need to find matched pairs of records in SQL Server, but each record can only be included in 1 pair. Once a record has been matched with a pair, it should be removed from consideration for any future pairs.
I have tried solutions involving…

Carly Reum
- 53
- 3
5
votes
0 answers
How to use xarray/dask/pandas/deepgraph for parallel pairwise correlation matrix in Python 3?
I'm trying to follow the tutorial on xarray's documentation: http://xarray.pydata.org/en/stable/dask.html#automatic-parallelization
My ultimate goal is to get a pairwise spearman correlation matrix from a dataset that has ~100,000 attributes which…

O.rka
- 29,847
- 68
- 194
- 309
5
votes
1 answer
Expand data.table with combinations of two columns given condition in another column
I have a data.table that gives me the connections between locations (origin and destination) for different bus routes (route_id).
library(data.table)
library(magrittr)
# data for reproducible example
dt <- data.table( origin = c('A','B','C', 'F',…

rafa.pereira
- 13,251
- 6
- 71
- 109
4
votes
3 answers
Convert combn output to matrix of type 'dist'
I have a dataframe in the following form:
dim1 dim2
1 Loc.1 0.325
2 Loc.2 0.325
3 Loc.3 0.321
4 Loc.4 0.256
5 Loc.5 0.255
I would like to compute the mean of each combination of two (2) elements within 'dim2'; and convert the output into a…

Chrys
- 313
- 3
- 10
4
votes
3 answers
Generating a matrix from pairwise comparison on a single vector in TensorFlow
I have a 1d vector and want to generate a matrix based on the pairwise comparison of the vector in TensorFlow. I need to compare each element in the vector to all the others (including itself), and if they are identical, the corresponding matrix…

ALeex
- 187
- 1
- 11
4
votes
4 answers
How to get the absolute difference between values in two columns in a matrix
I'm having a matrix like the following
i j value
[1,] 3 6 0.194201129
[2,] 3 5 0.164547043
[3,] 3 4 0.107149279
[4,] 4 3 0.004927017
[5,] 3 1 0.080454448
[6,] 1 2 0.003220612
[7,] 2 6 0.162313646
[8,] 3 3 0.114992628
[9,] 4 1…

J. Doe
- 619
- 4
- 16
4
votes
1 answer
Multiple Comparison Post-Hoc test for Levene's test
I'd like to do a pairwise comparison post-hoc test on Levene's test in R. I know how to do it in SAS using PROC GLM but I can't seem to figure out how to do it in R. Does anyone have any idea? In the example below I'd like to be able to test the…

Nathan
- 323
- 3
- 13
3
votes
1 answer
How to only test select pairwise comparisons using emmeans?
I have seen several examples how it might be possible to select desired pairwise comparisons, but unfortunately do not know how to apply that to my data.
Here is my abbreviated data set: https://www.dropbox.com/s/x9xjc9o0222rg0w/df.csv?dl=0
# FIXED…

user7395965
- 397
- 5
- 17
3
votes
1 answer
Compact Letter Display (CLD) from pairwise comparisons p-values
I have been struggling for a while to make my own CLD from a table of pairwise comparisons with p-values.
I know it is possible with multcomp, but I would like to generate my own DIY function that can be adapted for different post-hoc outputs.
Of…

jordi
- 91
- 1
- 7