Methods for binding objects of array classes along a given dimension
Source:R/genericMethods.R
, R/FLArray.R
dbind-methods.Rd
These methods can bind two or more objects of array-based classes (e.g. FLQuant), along the specified dimension.
Usage
dbind(x, y, ...)
# S4 method for FLArray,FLArray
dbind(x, y, ..., dim = 1)
qbind(...)
ybind(...)
ubind(...)
sbind(...)
abind(...)
ibind(...)
Arguments
- x
First object to bind
- y
Second object to bind
- ...
Other objects to bind
- dim
Dimension to bind on, numeric or character.
Details
The objects to bind must contain the same dimmames in all dimensions other than that used to bind, while dimnames in the selected one must differ. See the examples below for correct and incorrect uses.
Object are bound in the order they are provided, with no attempt to sort according to the dimnames of the chosen dimension.
The implementation is based around a single method (dbind), that operates along the dimension position or name indicated by the dim argument. A series of shortcut functions call the method for specific dimensions, with names related to the dimensions name they operate on (e.g. ybind for year).
Examples
# By iter
x <- FLQuant(rnorm(80000), dim=c(4,20,1,1,1,1000))
y <- FLQuant(rnorm(80000), dim=c(4,20,1,1,1,1000))
dimnames(y) <- list(iter=1001:2000)
ibind(x,y)
#> An object of class "FLQuant"
#> iters: 2000
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3
#> 1 -3.7713e-02(0.995) -1.2687e-02(0.973) 1.5154e-02(1.032)
#> 2 -1.3224e-02(0.966) -1.0555e-02(0.991) -2.2550e-02(1.025)
#> 3 2.1750e-02(0.980) 2.9565e-02(0.962) 4.1459e-02(0.968)
#> 4 -2.7687e-03(0.988) 1.7678e-02(1.008) 7.2145e-03(1.012)
#> year
#> quant 4 5 6
#> 1 -2.1827e-02(0.976) -1.5798e-03(0.959) 2.1379e-03(0.986)
#> 2 8.8087e-03(1.045) -5.8764e-04(0.965) -5.9665e-02(0.963)
#> 3 -3.6916e-02(0.948) 8.5833e-03(0.959) 1.8116e-03(1.009)
#> 4 1.0848e-02(0.984) -3.1862e-03(0.992) -3.4453e-03(1.000)
#> year
#> quant 7 8 9
#> 1 4.6533e-03(1.007) -2.2287e-02(1.022) 1.6809e-02(1.012)
#> 2 -3.8107e-03(0.962) -2.3684e-02(0.974) -3.8052e-03(0.976)
#> 3 -1.9502e-02(0.991) 2.6237e-03(0.967) -4.0798e-02(0.942)
#> 4 7.3690e-03(1.062) -1.6125e-02(1.001) -4.2905e-02(1.006)
#> year
#> quant 10 11 12
#> 1 1.8675e-02(1.055) -4.4969e-02(0.985) 1.9186e-02(0.996)
#> 2 -7.7795e-03(0.987) -5.8027e-02(1.008) 1.1617e-02(1.012)
#> 3 1.5719e-02(1.008) 2.4876e-02(1.011) -7.7333e-03(1.017)
#> 4 -5.6523e-04(1.078) -2.0627e-02(1.025) -4.3050e-02(1.036)
#> year
#> quant 13 14 15
#> 1 1.0276e-02(1.011) -2.6703e-02(1.029) 1.9256e-02(0.990)
#> 2 6.7860e-03(1.017) -2.5926e-02(1.021) -4.5632e-03(1.023)
#> 3 -5.3129e-02(1.004) 6.1973e-03(0.963) 6.4984e-02(0.993)
#> 4 -3.2984e-02(0.992) -1.4362e-02(0.999) 1.3916e-02(1.006)
#> year
#> quant 16 17 18
#> 1 1.8445e-02(0.990) 3.4325e-02(0.993) 8.2225e-03(0.982)
#> 2 -2.7584e-02(0.958) 2.8200e-02(1.038) -2.9007e-02(0.954)
#> 3 2.9244e-02(1.028) -1.5645e-02(1.007) 1.5251e-02(0.984)
#> 4 1.6419e-02(0.983) 1.1332e-03(0.931) 1.8837e-02(0.956)
#> year
#> quant 19 20
#> 1 1.0350e-02(0.991) 3.4880e-02(1.013)
#> 2 -3.0215e-03(1.013) -9.9286e-03(0.995)
#> 3 1.2160e-02(0.995) -5.7102e-04(0.987)
#> 4 6.6341e-06(1.015) -8.8421e-03(0.961)
#>
#> units: NA
# By quant (age)
x <- FLQuant(1, dimnames=list(age=1:3, year=1:10))
y <- FLQuant(2, dimnames=list(age=4:12, year=1:10))
qbind(x, y)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 1 2 3 4 5 6 7 8 9 10
#> 1 1 1 1 1 1 1 1 1 1 1
#> 2 1 1 1 1 1 1 1 1 1 1
#> 3 1 1 1 1 1 1 1 1 1 1
#> 4 2 2 2 2 2 2 2 2 2 2
#> 5 2 2 2 2 2 2 2 2 2 2
#> 6 2 2 2 2 2 2 2 2 2 2
#> 7 2 2 2 2 2 2 2 2 2 2
#> 8 2 2 2 2 2 2 2 2 2 2
#> 9 2 2 2 2 2 2 2 2 2 2
#> 10 2 2 2 2 2 2 2 2 2 2
#> 11 2 2 2 2 2 2 2 2 2 2
#> 12 2 2 2 2 2 2 2 2 2 2
#>
#> units: NA
# By year
x <- FLQuant(1, dimnames=list(age=1:3, year=1:10))
y <- FLQuant(2, dimnames=list(age=1:3, year=11:20))
z <- FLQuant(3, dimnames=list(age=1:3, year=21:30))
ybind(x, y, z)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#> 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
#> 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
#> 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
#> year
#> age 29 30
#> 1 3 3
#> 2 3 3
#> 3 3 3
#>
#> units: NA
# By season
x <- FLQuant(1, dimnames=list(year=1:10, season=1:2))
y <- FLQuant(2, dimnames=list(year=1:10, season=3:4))
sbind(x, y)
#> An object of class "FLQuant"
#> , , unit = unique, season = 1, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8 9 10
#> all 1 1 1 1 1 1 1 1 1 1
#>
#> , , unit = unique, season = 2, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8 9 10
#> all 1 1 1 1 1 1 1 1 1 1
#>
#> , , unit = unique, season = 3, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8 9 10
#> all 2 2 2 2 2 2 2 2 2 2
#>
#> , , unit = unique, season = 4, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8 9 10
#> all 2 2 2 2 2 2 2 2 2 2
#>
#> units: NA