rray_flatten() squashes the dimensionality of
x so that the result is a
A vector, matrix, array or rray.
A 1D object with the same container type as
This function is similar to
as.vector(), but keeps the class of the object
and can keep the dimension names if applicable.
Dimension names are kept using the same rules that would be applied if you
would have called
rray_reshape(x, prod(rray_dim(x))). Essentially this
means that names in the first dimension are kept if
x is either already
a 1D vector, or a higher dimensional object with 1's in all dimensions
except for the first one.
#> <rray<int>> #>  1 2 3 4 5 6 7 8 9 10# Dimension names are kept here # (2) -> (2) y <- rray(1:2) %>% rray_set_axis_names(1, letters[1:2]) rray_flatten(y)#> <rray<int>> #> a b #> 1 2# And they are kept here # (2, 1) -> (2) y_one_col <- rray_reshape(y, c(2, 1)) rray_flatten(y_one_col)#> <rray<int>> #> a b #> 1 2# But not here, since the size of the first dim changes # (1, 2) -> (2) y_one_row <- t(y_one_col) rray_flatten(y_one_row)#> <rray<int>> #>  1 2