Skip to contents

Bind multidimensional array-like objects along any dimension.

NOTE: This man page is for the abind S4 generic function defined in the S4Arrays package. See ?abind::abind for the default method (defined in the abind package). Bioconductor packages can define specific methods for objects not supported by the default method.

Usage

## Bind array-like objects along any dimension:
abind(..., along=NULL, rev.along=NULL)

## Bind array-like objects along their first or second dimension:
arbind(...)
acbind(...)

Arguments

...

The array-like objects to bind.

along, rev.along

See ?abind::abind for a description of these arguments.

Value

An array-like object, typically of the same class as the input objects if they all have the same class.

See also

  • abind::abind in the abind package for the default abind method.

  • rbind and cbind in the base package for the corresponding operations on matrix-like objects.

Examples

a1 <- array(1:60, c(3, 5, 4),
            dimnames=list(NULL, paste0("A1y", 1:5), NULL))
a2 <- array(101:240, c(7, 5, 4),
            dimnames=list(paste0("A2x", 1:7), paste0("A2y", 1:5), NULL))
a3 <- array(10001:10100, c(5, 5, 4),
            dimnames=list(paste0("A3x", 1:5), NULL, paste0("A3z", 1:4)))

abind(a1, a2, a3, along=1)  # same as 'arbind(a1, a2, a3)'
#> , , A3z1
#> 
#>       A1y1  A1y2  A1y3  A1y4  A1y5
#>          1     4     7    10    13
#>          2     5     8    11    14
#>          3     6     9    12    15
#> A2x1   101   108   115   122   129
#> A2x2   102   109   116   123   130
#> A2x3   103   110   117   124   131
#> A2x4   104   111   118   125   132
#> A2x5   105   112   119   126   133
#> A2x6   106   113   120   127   134
#> A2x7   107   114   121   128   135
#> A3x1 10001 10006 10011 10016 10021
#> A3x2 10002 10007 10012 10017 10022
#> A3x3 10003 10008 10013 10018 10023
#> A3x4 10004 10009 10014 10019 10024
#> A3x5 10005 10010 10015 10020 10025
#> 
#> , , A3z2
#> 
#>       A1y1  A1y2  A1y3  A1y4  A1y5
#>         16    19    22    25    28
#>         17    20    23    26    29
#>         18    21    24    27    30
#> A2x1   136   143   150   157   164
#> A2x2   137   144   151   158   165
#> A2x3   138   145   152   159   166
#> A2x4   139   146   153   160   167
#> A2x5   140   147   154   161   168
#> A2x6   141   148   155   162   169
#> A2x7   142   149   156   163   170
#> A3x1 10026 10031 10036 10041 10046
#> A3x2 10027 10032 10037 10042 10047
#> A3x3 10028 10033 10038 10043 10048
#> A3x4 10029 10034 10039 10044 10049
#> A3x5 10030 10035 10040 10045 10050
#> 
#> , , A3z3
#> 
#>       A1y1  A1y2  A1y3  A1y4  A1y5
#>         31    34    37    40    43
#>         32    35    38    41    44
#>         33    36    39    42    45
#> A2x1   171   178   185   192   199
#> A2x2   172   179   186   193   200
#> A2x3   173   180   187   194   201
#> A2x4   174   181   188   195   202
#> A2x5   175   182   189   196   203
#> A2x6   176   183   190   197   204
#> A2x7   177   184   191   198   205
#> A3x1 10051 10056 10061 10066 10071
#> A3x2 10052 10057 10062 10067 10072
#> A3x3 10053 10058 10063 10068 10073
#> A3x4 10054 10059 10064 10069 10074
#> A3x5 10055 10060 10065 10070 10075
#> 
#> , , A3z4
#> 
#>       A1y1  A1y2  A1y3  A1y4  A1y5
#>         46    49    52    55    58
#>         47    50    53    56    59
#>         48    51    54    57    60
#> A2x1   206   213   220   227   234
#> A2x2   207   214   221   228   235
#> A2x3   208   215   222   229   236
#> A2x4   209   216   223   230   237
#> A2x5   210   217   224   231   238
#> A2x6   211   218   225   232   239
#> A2x7   212   219   226   233   240
#> A3x1 10076 10081 10086 10091 10096
#> A3x2 10077 10082 10087 10092 10097
#> A3x3 10078 10083 10088 10093 10098
#> A3x4 10079 10084 10089 10094 10099
#> A3x5 10080 10085 10090 10095 10100
#> 

m2 <- matrix(1:35, nrow=7)
abind(m2, a2, along=3)
#> , , 1
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1    1    8   15   22   29
#> A2x2    2    9   16   23   30
#> A2x3    3   10   17   24   31
#> A2x4    4   11   18   25   32
#> A2x5    5   12   19   26   33
#> A2x6    6   13   20   27   34
#> A2x7    7   14   21   28   35
#> 
#> , , 2
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  101  108  115  122  129
#> A2x2  102  109  116  123  130
#> A2x3  103  110  117  124  131
#> A2x4  104  111  118  125  132
#> A2x5  105  112  119  126  133
#> A2x6  106  113  120  127  134
#> A2x7  107  114  121  128  135
#> 
#> , , 3
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  136  143  150  157  164
#> A2x2  137  144  151  158  165
#> A2x3  138  145  152  159  166
#> A2x4  139  146  153  160  167
#> A2x5  140  147  154  161  168
#> A2x6  141  148  155  162  169
#> A2x7  142  149  156  163  170
#> 
#> , , 4
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  171  178  185  192  199
#> A2x2  172  179  186  193  200
#> A2x3  173  180  187  194  201
#> A2x4  174  181  188  195  202
#> A2x5  175  182  189  196  203
#> A2x6  176  183  190  197  204
#> A2x7  177  184  191  198  205
#> 
#> , , 5
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  206  213  220  227  234
#> A2x2  207  214  221  228  235
#> A2x3  208  215  222  229  236
#> A2x4  209  216  223  230  237
#> A2x5  210  217  224  231  238
#> A2x6  211  218  225  232  239
#> A2x7  212  219  226  233  240
#> 
abind(a2, m2, along=3)
#> , , 1
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  101  108  115  122  129
#> A2x2  102  109  116  123  130
#> A2x3  103  110  117  124  131
#> A2x4  104  111  118  125  132
#> A2x5  105  112  119  126  133
#> A2x6  106  113  120  127  134
#> A2x7  107  114  121  128  135
#> 
#> , , 2
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  136  143  150  157  164
#> A2x2  137  144  151  158  165
#> A2x3  138  145  152  159  166
#> A2x4  139  146  153  160  167
#> A2x5  140  147  154  161  168
#> A2x6  141  148  155  162  169
#> A2x7  142  149  156  163  170
#> 
#> , , 3
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  171  178  185  192  199
#> A2x2  172  179  186  193  200
#> A2x3  173  180  187  194  201
#> A2x4  174  181  188  195  202
#> A2x5  175  182  189  196  203
#> A2x6  176  183  190  197  204
#> A2x7  177  184  191  198  205
#> 
#> , , 4
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1  206  213  220  227  234
#> A2x2  207  214  221  228  235
#> A2x3  208  215  222  229  236
#> A2x4  209  216  223  230  237
#> A2x5  210  217  224  231  238
#> A2x6  211  218  225  232  239
#> A2x7  212  219  226  233  240
#> 
#> , , 5
#> 
#>      A2y1 A2y2 A2y3 A2y4 A2y5
#> A2x1    1    8   15   22   29
#> A2x2    2    9   16   23   30
#> A2x3    3   10   17   24   31
#> A2x4    4   11   18   25   32
#> A2x5    5   12   19   26   33
#> A2x6    6   13   20   27   34
#> A2x7    7   14   21   28   35
#> 

abind(m2, m2+0.5, rev.along=0)  # same as 'abind(m2, m2+0.5, along=3)'
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    8   15   22   29
#> [2,]    2    9   16   23   30
#> [3,]    3   10   17   24   31
#> [4,]    4   11   18   25   32
#> [5,]    5   12   19   26   33
#> [6,]    6   13   20   27   34
#> [7,]    7   14   21   28   35
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]  1.5  8.5 15.5 22.5 29.5
#> [2,]  2.5  9.5 16.5 23.5 30.5
#> [3,]  3.5 10.5 17.5 24.5 31.5
#> [4,]  4.5 11.5 18.5 25.5 32.5
#> [5,]  5.5 12.5 19.5 26.5 33.5
#> [6,]  6.5 13.5 20.5 27.5 34.5
#> [7,]  7.5 14.5 21.5 28.5 35.5
#>