ID EN
Miscellaneous

aperm

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Ubah urutan array dengan mengubah dimensinya dan mengubah ukurannya secara opsional.

Syntax

R
aperm(a, perm, …)
# S3 method for default
aperm(a, perm = NULL, resize = TRUE, …)
# S3 method for table
aperm(a, perm = NULL, resize = TRUE, keep.class = TRUE, …)

Arguments

Parameter Deskripsi
a the array to be transposed.
perm the subscript permutation vector, usually a permutation of the integers 1:n, where n is the number of dimensions of a. When a has named dimnames, it can be a character vector of length n giving a permutation of those names. The default (used whenever perm has zero length) is to reverse the order of the dimensions.
resize a flag indicating whether the vector should be resized as well as having its elements reordered (default TRUE).
keep.class logical indicating if the result should be of the same class as a.
… potential further arguments of methods.

Return Value

Versi array a yang dialihkan, dengan subskrip yang diijinkan seperti yang ditunjukkan oleh array perm. Jika pengubahan ukuran BENAR, array akan dibentuk ulang dan elemen-elemennya juga diubah, nama dimnya juga diubah; jika resize = FALSE maka objek yang dikembalikan memiliki dimensi yang sama dengan a, dan nama dimnya dihilangkan. Dalam setiap kasus, atribut lain disalin dari a. Fungsi t menyediakan cara yang lebih cepat dan nyaman untuk mentransposisi matriks.

Contoh

Example
R
# NOT RUN {
# interchange the first two subscripts on a 3-way array x
x  <- array(1:24, 2:4)
xt <- aperm(x, c(2,1,3))
stopifnot(t(xt[,,2]) == x[,,2],
          t(xt[,,3]) == x[,,3],
          t(xt[,,4]) == x[,,4])

UCB <- aperm(UCBAdmissions, c(2,1,3))
UCB[1,,]
summary(UCB) # UCB is still a contingency table
# }

See Also

t to transpose matrices.