Apply the given function to every pair in the given datalist. Function either symmetrical (i.e. fun(x,y) == fun(y,x)) or assymmetrical (i.e. fun(x,y) != fun(y,x)).

apply_symm(.datalist, .fun, ..., .diag = NA, .verbose = TRUE)

apply_asymm(.datalist, .fun, ..., .diag = NA, .verbose = TRUE)

Arguments

.datalist

List with some data.frames.

.fun

Function to apply, which return basic class value.

...

Arguments passsed to .fun.

.diag

Either NA for NA or something else != NULL for .fun(x,x).

.verbose

if TRUE then output a progress bar.

Value

Matrix with values M[i,j] = fun(datalist[i], datalist[j])

Examples

data(immdata)
apply_symm(immdata$data, function(x, y) {
  nrow(x) + nrow(y)
})
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================| 100%
#>         A2-i129 A2-i131 A2-i133 A2-i132 A4-i191 A4-i192   MS1   MS2   MS3   MS4
#> A2-i129      NA   13085   12925   13381   11678   12355 11937 13677 12993 13979
#> A2-i131   13085      NA   12946   13402   11699   12376 11958 13698 13014 14000
#> A2-i133   12925   12946      NA   13242   11539   12216 11798 13538 12854 13840
#> A2-i132   13381   13402   13242      NA   11995   12672 12254 13994 13310 14296
#> A4-i191   11678   11699   11539   11995      NA   10969 10551 12291 11607 12593
#> A4-i192   12355   12376   12216   12672   10969      NA 11228 12968 12284 13270
#> MS1       11937   11958   11798   12254   10551   11228    NA 12550 11866 12852
#> MS2       13677   13698   13538   13994   12291   12968 12550    NA 13606 14592
#> MS3       12993   13014   12854   13310   11607   12284 11866 13606    NA 13908
#> MS4       13979   14000   13840   14296   12593   13270 12852 14592 13908    NA
#> MS5       12189   12210   12050   12506   10803   11480 11062 12802 12118 13104
#> MS6       13941   13962   13802   14258   12555   13232 12814 14554 13870 14856
#>           MS5   MS6
#> A2-i129 12189 13941
#> A2-i131 12210 13962
#> A2-i133 12050 13802
#> A2-i132 12506 14258
#> A4-i191 10803 12555
#> A4-i192 11480 13232
#> MS1     11062 12814
#> MS2     12802 14554
#> MS3     12118 13870
#> MS4     13104 14856
#> MS5        NA 13066
#> MS6     13066    NA