bind.Rd
Given multiple tidytensors, or a list of tidytensors, binds them together to create a tidytensor of higher rank. For example, bind(x, y, z) where x, y, and z have shape [2, 3, 5] returns a new tidytensor of shape [3, 2, 3, 5].
bind(..., new_rank_name = NULL)
one or more tidytensors, or a single list of them, to bind
a name (length-1 character vector) for the newly created rank.
a new tidytensor.
All input tidytensors must have the same shape. It's also possible to set a new rankname for the newly created dimension; if ranknames were prevously unset lower ranknames are set to NA. If the input ranknames conflict, only those of the first input tidytensor will be used, and a warning will be generated.
# Three tidytensors of the same shape
t1 <- as.tidytensor(array(1:(3 * 4 * 5), dim = c(3, 4, 5)))
t2 <- as.tidytensor(array(10 * 1:(3 * 4 * 5), dim = c(3, 4, 5)))
t3 <- as.tidytensor(array(100 * 1:(3 * 4 * 5), dim = c(3, 4, 5)))
ranknames(t1) <- c("sample", "row", "col")
ranknames(t2) <- c("sample", "row", "col")
ranknames(t3) <- c("sample", "row", "col")
t4 <- bind(t1, t2, t3, new_rank_name = "batch")
print(t4)
#> # Rank 4 tensor, shape: (3, 3, 4, 5), ranknames: batch, sample, row, col
#> | # Rank 3 tensor, shape: (3, 4, 5)
#> | | # Rank 2 tensor, shape: (4, 5)
#> | | 1 13 25 37 49
#> | | 4 16 28 40 52
#> | | 7 19 31 43 55
#> | | 10 22 34 46 58
#> | | # ...
#> | # ...