modify_along_dim | R Documentation |
This function can be thought of as a version of base::apply()
that is
guaranteed to return a object of the same dimensions as it was input. It also
generally preserves attributes, as it's built on top of [<-
.
modify_along_dim(X, which_dim, .f, ...)
modify_along_rows(X, .f, ...)
modify_along_cols(X, .f, ...)
X |
An array, or a list of arrays |
which_dim |
integer vector of dimensions to modify at |
.f |
a function or formula defining a function(same semantics as
|
... |
passed on to |
An array, or if X
was a list, a list of arrays of the same shape as
was passed in.
x <- array(1:6, 1:3)
modify_along_dim(x, 3, ~mean(.x))
modify_along_dim(x, 3, ~.x/mean(.x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.