Applies an element-wise operation between an array and the supplied statistics broadcast over the requested margins while preserving dimension names. Matches the semantics of [base::sweep()].
array_sweep(x, MARGIN, STATS, FUN = "*")Numeric array.
Integer or character vector identifying the margins over which `STATS` should be swept. Character margins are matched against the names of `dimnames(x)`.
Numeric array or vector that is broadcastable over `MARGIN`.
Character scalar choosing the operation. Supported values are `"+"`, `"-"`, `"*"`, and `"/"`.
An array with the same shape (and dimnames) as `x` containing the swept result.