Description Usage Arguments Details Value Examples
rray_squeeze() is conceptually similar to base::drop(), but it allows
for the specification of specific dimensions to squeeze.
1 | rray_squeeze(x, axes = NULL)
|
x |
A vector, matrix, array or rray. |
axes |
An integer vector specifying the size 1 dimensions to drop. If
|
The dimension name handling of rray_squeeze() is essentially identical to
drop(), but some explanation is always helpful:
Dimension names are removed from the axes that are squeezed. So squeezing
a (2, 1, 2) object results in a (2, 2) object using the dimension names
from the original first and third dimensions.
When all dimensions are squeezed, as in the case of (1, 1, 1), then
the first dimension names that are found are the ones that are used in the
(1) result.
x with the axes dropped, if possible.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # (10, 1) -> (10)
x <- rray(1:10, c(10, 1))
rray_squeeze(x)
# Multiple squeezed dimensions
# (10, 1, 1) -> (10)
y <- rray_reshape(x, c(10, 1, 1))
rray_squeeze(y)
# Use `axes` to specify dimensions to drop
# (10, 1, 1) -> drop 2 -> (10, 1)
rray_squeeze(y, axes = 2)
# Dimension names are kept here
# (10, 1) -> (10)
x <- rray_set_row_names(x, letters[1:10])
rray_squeeze(x)
# And they are kept here
# (1, 10) -> (10)
rray_squeeze(t(x))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.